Answer the question
In order to leave comments, you need to log in
How to solve such problem with pyppeteer, asyncio and pyrogram?
There is an event for the appearance of a new message, from which you need to call a screenshot on pyppeteer in a loop
Looks like this:
....
async def screenshot(stock, loop, date_msg):
await launch(headless=True, defaultViewport=None, args=['--no-sandbox'])
.....
....
@client.on_message()
def msg_handler(client, message):
.......
for row in result:
loop = asyncio.get_event_loop()
loop.run_until_complete(screenshot(stock.upper(), loop, date_msg))
screens.append(InputMediaPhoto(os.path.join(BASEDIR, stock.upper()+".png")))
RuntimeError: There is no current event loop in thread 'Handler_0'
loop1 = asyncio.new_event_loop()
asyncio.set_event_loop(loop1)
loop = asyncio.get_event_loop()
loop.run_until_complete(screenshot(stock.upper(), loop, date_msg))
signal only works in main thread
await launch(headless=True, defaultViewport=None, args=['--no-sandbox'], handleSIGINT=False, handleSIGTERM=False, handleSIGHUP=False)
Answer the question
In order to leave comments, you need to log in
In short, I decided through multiprocessing - I wrapped it in a separate process and, accordingly, inside this process, the thread is the main one and everything works
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question