Jojo image generated in {total_time:.2f} seconds.
Browse files
app.py
CHANGED
@@ -46,12 +46,15 @@ async def jojo(ctx):
|
|
46 |
async def run_jojo(ctx):
|
47 |
safety = await safety_checks(ctx)
|
48 |
if safety:
|
|
|
49 |
#discord before
|
50 |
attachment = await discord_before(ctx)
|
51 |
#generation
|
52 |
generated_image = await generation(attachment)
|
53 |
#discord after
|
54 |
-
|
|
|
|
|
55 |
|
56 |
async def discord_before(ctx):
|
57 |
await asyncio.gather(
|
@@ -79,9 +82,9 @@ async def generation(attachment):
|
|
79 |
print(activethreadcount)
|
80 |
return generated_image
|
81 |
|
82 |
-
async def discord_after(ctx, generated_image):
|
83 |
await asyncio.gather(
|
84 |
-
ctx.send(f'{ctx.author.mention}
|
85 |
asyncio.sleep(0.5),
|
86 |
ctx.message.remove_reaction('⌛', bot.user),
|
87 |
asyncio.sleep(0.5),
|
@@ -99,17 +102,6 @@ async def safety_checks(ctx):
|
|
99 |
)
|
100 |
return None
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
#--------------------------------------------------------
|
114 |
def get_total_threads():
|
115 |
return multiprocessing.cpu_count()
|
@@ -135,26 +127,3 @@ demo.launch()
|
|
135 |
#--------------------------------------------------------
|
136 |
|
137 |
|
138 |
-
|
139 |
-
'''
|
140 |
-
|
141 |
-
|
142 |
-
'''
|
143 |
-
|
144 |
-
|
145 |
-
'''
|
146 |
-
def blocking_io():
|
147 |
-
#generate
|
148 |
-
#return image
|
149 |
-
|
150 |
-
async def main():
|
151 |
-
loop = asyncio.get_running_loop()
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
exeresult = await loop.run_in_executor(
|
156 |
-
None, blocking_io)
|
157 |
-
print('default thread pool', exeresult)
|
158 |
-
|
159 |
-
'''
|
160 |
-
|
|
|
46 |
async def run_jojo(ctx):
|
47 |
safety = await safety_checks(ctx)
|
48 |
if safety:
|
49 |
+
start_time = time.time()
|
50 |
#discord before
|
51 |
attachment = await discord_before(ctx)
|
52 |
#generation
|
53 |
generated_image = await generation(attachment)
|
54 |
#discord after
|
55 |
+
end_time = time.time()
|
56 |
+
total_time = end_time - start_time
|
57 |
+
await discord_after(ctx, generated_image, total_time)
|
58 |
|
59 |
async def discord_before(ctx):
|
60 |
await asyncio.gather(
|
|
|
82 |
print(activethreadcount)
|
83 |
return generated_image
|
84 |
|
85 |
+
async def discord_after(ctx, generated_image, total_time):
|
86 |
await asyncio.gather(
|
87 |
+
ctx.send(f'{ctx.author.mention} Jojo image generated in {total_time:.2f} seconds.', file=discord.File(generated_image)),
|
88 |
asyncio.sleep(0.5),
|
89 |
ctx.message.remove_reaction('⌛', bot.user),
|
90 |
asyncio.sleep(0.5),
|
|
|
102 |
)
|
103 |
return None
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
#--------------------------------------------------------
|
106 |
def get_total_threads():
|
107 |
return multiprocessing.cpu_count()
|
|
|
127 |
#--------------------------------------------------------
|
128 |
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|