Use client.rnd_id()
This commit is contained in:
parent
744832f697
commit
2cce3aa833
|
@ -41,7 +41,8 @@ async def pyexec(client, message):
|
||||||
if ex.msg != "'return' with value in async generator":
|
if ex.msg != "'return' with value in async generator":
|
||||||
raise
|
raise
|
||||||
exx = _gf(obody)
|
exx = _gf(obody)
|
||||||
reply = await message.reply_text(f'Executing <code>{hash(UniqueExecReturnIdentifier)}</code>...')
|
rnd_id = client.rnd_id()
|
||||||
|
reply = await message.reply_text(f'Executing <code>{rnd_id}</code>...')
|
||||||
oasync_obj = exx(client, client, message, message, reply, message.reply_to_message, message.reply_to_message, UniqueExecReturnIdentifier)
|
oasync_obj = exx(client, client, message, message, reply, message.reply_to_message, message.reply_to_message, UniqueExecReturnIdentifier)
|
||||||
if inspect.isasyncgen(oasync_obj):
|
if inspect.isasyncgen(oasync_obj):
|
||||||
async def async_obj():
|
async def async_obj():
|
||||||
|
@ -58,18 +59,18 @@ async def pyexec(client, message):
|
||||||
sys.stdout = wrapped_stdout
|
sys.stdout = wrapped_stdout
|
||||||
sys.stderr = wrapped_stderr
|
sys.stderr = wrapped_stderr
|
||||||
task = asyncio.create_task(async_obj())
|
task = asyncio.create_task(async_obj())
|
||||||
exec_tasks[hash(UniqueExecReturnIdentifier)] = task
|
exec_tasks[rnd_id] = task
|
||||||
returned = await task
|
returned = await task
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
sys.stdout = stdout
|
sys.stdout = stdout
|
||||||
sys.stderr = stderr
|
sys.stderr = stderr
|
||||||
exec_tasks.pop(hash(UniqueExecReturnIdentifier), None)
|
exec_tasks.pop(rnd_id, None)
|
||||||
await reply.edit_text('Cancelled')
|
await reply.edit_text('Cancelled')
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
sys.stdout = stdout
|
sys.stdout = stdout
|
||||||
sys.stderr = stderr
|
sys.stderr = stderr
|
||||||
exec_tasks.pop(hash(UniqueExecReturnIdentifier), None)
|
exec_tasks.pop(rnd_id, None)
|
||||||
wrapped_stderr.seek(0)
|
wrapped_stderr.seek(0)
|
||||||
wrapped_stdout.seek(0)
|
wrapped_stdout.seek(0)
|
||||||
output = ''
|
output = ''
|
||||||
|
|
Loading…
Reference in New Issue