lunarflu HF Staff commited on
Commit
0615999
·
1 Parent(s): 411d4c3

async with semaphore:

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -19,7 +19,7 @@ import concurrent.futures
19
  import multiprocessing
20
 
21
 
22
-
23
 
24
  DFIF_TOKEN = os.getenv('HF_TOKEN')
25
  DISCORD_TOKEN = os.environ.get("GRADIOTEST_TOKEN", None)
@@ -77,7 +77,8 @@ async def discord_before(ctx):
77
  async def generation(ctx, attachment, start_time):
78
  if attachment:
79
  style = 'JoJo'
80
- im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
 
81
  #im = await asyncio.to_thread(jojogan.predict, attachment.url, style)
82
  #im = jojogan.predict(attachment.url, style)
83
 
 
19
  import multiprocessing
20
 
21
 
22
+ semaphore = asyncio.Semaphore(4)
23
 
24
  DFIF_TOKEN = os.getenv('HF_TOKEN')
25
  DISCORD_TOKEN = os.environ.get("GRADIOTEST_TOKEN", None)
 
77
  async def generation(ctx, attachment, start_time):
78
  if attachment:
79
  style = 'JoJo'
80
+ async with semaphore:
81
+ im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
82
  #im = await asyncio.to_thread(jojogan.predict, attachment.url, style)
83
  #im = jojogan.predict(attachment.url, style)
84