activethreadcount = active_count()
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import discord
|
2 |
import os
|
3 |
import threading
|
|
|
4 |
import gradio as gr
|
5 |
import requests
|
6 |
import json
|
@@ -37,6 +38,12 @@ async def lunar(ctx):
|
|
37 |
|
38 |
@bot.command()
|
39 |
async def jojo(ctx):
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
attachment = await discord_before(ctx)
|
41 |
if attachment:
|
42 |
asyncio.create_task(generation(ctx, attachment))
|
@@ -49,6 +56,12 @@ async def discord_before(ctx):
|
|
49 |
ctx.message.add_reaction('β')
|
50 |
)
|
51 |
attachment = ctx.message.attachments[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
return attachment
|
53 |
else:
|
54 |
await asyncio.gather(
|
@@ -63,6 +76,12 @@ async def generation(ctx, attachment):
|
|
63 |
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
|
64 |
#im = await asyncio.to_thread(jojogan.predict, attachment.url, style)
|
65 |
#im = jojogan.predict(attachment.url, style)
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
await asyncio.gather(
|
67 |
ctx.send(f'{ctx.author.mention} Here is the jojo version of it'),
|
68 |
ctx.send(file=discord.File(im)),
|
@@ -70,13 +89,7 @@ async def generation(ctx, attachment):
|
|
70 |
ctx.message.add_reaction('β
')
|
71 |
)
|
72 |
|
73 |
-
|
74 |
-
await asyncio.gather(
|
75 |
-
ctx.send(f'{ctx.author.mention} Here is the jojo version of it'),
|
76 |
-
ctx.send(file=discord.File(im)),
|
77 |
-
ctx.message.remove_reaction('β', bot.user),
|
78 |
-
ctx.message.add_reaction('β
')
|
79 |
-
)
|
80 |
|
81 |
|
82 |
|
@@ -86,8 +99,12 @@ def get_total_threads():
|
|
86 |
return multiprocessing.cpu_count()
|
87 |
|
88 |
total_threads = get_total_threads()
|
89 |
-
print("Total
|
90 |
|
|
|
|
|
|
|
|
|
91 |
|
92 |
def run_bot():
|
93 |
bot.run(DISCORD_TOKEN)
|
@@ -104,7 +121,13 @@ demo.launch()
|
|
104 |
|
105 |
|
106 |
'''
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
'''
|
110 |
|
|
|
1 |
import discord
|
2 |
import os
|
3 |
import threading
|
4 |
+
from threading import active_count
|
5 |
import gradio as gr
|
6 |
import requests
|
7 |
import json
|
|
|
38 |
|
39 |
@bot.command()
|
40 |
async def jojo(ctx):
|
41 |
+
|
42 |
+
# get the number of active threads
|
43 |
+
activethreadcount = active_count()
|
44 |
+
# report the number of active threads
|
45 |
+
print(activethreadcount)
|
46 |
+
|
47 |
attachment = await discord_before(ctx)
|
48 |
if attachment:
|
49 |
asyncio.create_task(generation(ctx, attachment))
|
|
|
56 |
ctx.message.add_reaction('β')
|
57 |
)
|
58 |
attachment = ctx.message.attachments[0]
|
59 |
+
|
60 |
+
# get the number of active threads
|
61 |
+
activethreadcount = active_count()
|
62 |
+
# report the number of active threads
|
63 |
+
print(activethreadcount)
|
64 |
+
|
65 |
return attachment
|
66 |
else:
|
67 |
await asyncio.gather(
|
|
|
76 |
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
|
77 |
#im = await asyncio.to_thread(jojogan.predict, attachment.url, style)
|
78 |
#im = jojogan.predict(attachment.url, style)
|
79 |
+
|
80 |
+
# get the number of active threads
|
81 |
+
activethreadcount = active_count()
|
82 |
+
# report the number of active threads
|
83 |
+
print(activethreadcount)
|
84 |
+
|
85 |
await asyncio.gather(
|
86 |
ctx.send(f'{ctx.author.mention} Here is the jojo version of it'),
|
87 |
ctx.send(file=discord.File(im)),
|
|
|
89 |
ctx.message.add_reaction('β
')
|
90 |
)
|
91 |
|
92 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
|
95 |
|
|
|
99 |
return multiprocessing.cpu_count()
|
100 |
|
101 |
total_threads = get_total_threads()
|
102 |
+
print("Total cpus:", total_threads)
|
103 |
|
104 |
+
# get the number of active threads
|
105 |
+
activethreadcount = active_count()
|
106 |
+
# report the number of active threads
|
107 |
+
print(activethreadcount)
|
108 |
|
109 |
def run_bot():
|
110 |
bot.run(DISCORD_TOKEN)
|
|
|
121 |
|
122 |
|
123 |
'''
|
124 |
+
async def discord_after(ctx, im):
|
125 |
+
await asyncio.gather(
|
126 |
+
ctx.send(f'{ctx.author.mention} Here is the jojo version of it'),
|
127 |
+
ctx.send(file=discord.File(im)),
|
128 |
+
ctx.message.remove_reaction('β', bot.user),
|
129 |
+
ctx.message.add_reaction('β
')
|
130 |
+
)
|
131 |
|
132 |
'''
|
133 |
|