Update app.py
Browse files
app.py
CHANGED
@@ -39,7 +39,7 @@ async def active(ctx):
|
|
39 |
await ctx.message.reply(f'active threads: {activethreadcount}')
|
40 |
|
41 |
@bot.command()
|
42 |
-
async def jojo(ctx):
|
43 |
|
44 |
# get the number of active threads
|
45 |
activethreadcount = active_count()
|
@@ -48,7 +48,7 @@ async def jojo(ctx):
|
|
48 |
start_time = time.time()
|
49 |
attachment = await discord_before(ctx)
|
50 |
if attachment:
|
51 |
-
asyncio.create_task(generation(ctx, attachment, start_time))
|
52 |
#await generation(ctx, attachment)
|
53 |
|
54 |
async def discord_before(ctx):
|
@@ -74,12 +74,12 @@ async def discord_before(ctx):
|
|
74 |
)
|
75 |
return None
|
76 |
|
77 |
-
async def generation(ctx, attachment, start_time):
|
78 |
if attachment:
|
79 |
style = 'JoJo'
|
80 |
|
81 |
with semaphore:
|
82 |
-
|
83 |
#im = await asyncio.to_thread(jojogan.predict, attachment.url, style)
|
84 |
#im = jojogan.predict(attachment.url, style)
|
85 |
|
|
|
39 |
await ctx.message.reply(f'active threads: {activethreadcount}')
|
40 |
|
41 |
@bot.command()
|
42 |
+
async def jojo(ctx, semaphore):
|
43 |
|
44 |
# get the number of active threads
|
45 |
activethreadcount = active_count()
|
|
|
48 |
start_time = time.time()
|
49 |
attachment = await discord_before(ctx)
|
50 |
if attachment:
|
51 |
+
asyncio.create_task(generation(ctx, attachment, start_time, semaphore))
|
52 |
#await generation(ctx, attachment)
|
53 |
|
54 |
async def discord_before(ctx):
|
|
|
74 |
)
|
75 |
return None
|
76 |
|
77 |
+
async def generation(ctx, attachment, start_time, semaphore):
|
78 |
if attachment:
|
79 |
style = 'JoJo'
|
80 |
|
81 |
with semaphore:
|
82 |
+
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
|
83 |
#im = await asyncio.to_thread(jojogan.predict, attachment.url, style)
|
84 |
#im = jojogan.predict(attachment.url, style)
|
85 |
|