Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crontab stopped running #34

Open
Olesp opened this issue Nov 1, 2022 · 5 comments
Open

Crontab stopped running #34

Olesp opened this issue Nov 1, 2022 · 5 comments

Comments

@Olesp
Copy link

Olesp commented Nov 1, 2022

I've created a crontab in my code and deployed it to a server.
Everything ran fine until one month ago i'd say.
Now my code run, but the crontab never get run.
No idea why.
I'll provide as much info as needed.
Infos :
Python 3.10.6

Modules:
aiocron-1.8
pyairtable-1.3.0
Jinja2-3.1.2
discord.py-2.0.1
aiohttp
aiofiles

@aiocron.crontab("*15 * * * *")
async def gather_new_missions():
    doing stuff here

If you have any idea, even running it locally with cron set to everyminute doesn't do anything

@gawel
Copy link
Owner

gawel commented Nov 1, 2022

Probably a dupplicate of a known issue with aiohttp See #21

@Olesp
Copy link
Author

Olesp commented Nov 1, 2022

I'm not sure to understand the issue you linked. It used to work, even when I don't even use the aiohttp in the cron function.
Could you please explain how this module impact my code after working for a while ?

@gawel
Copy link
Owner

gawel commented Nov 1, 2022

aiohttp use a new event loop when none is specified. this break coroutines initiated with the original event loop

https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web.py#L487

just use web.run_app(loop=asyncio.get_eventloop())

@Olesp
Copy link
Author

Olesp commented Nov 1, 2022

@aiocron.crontab("*/15 * * * *")
async def gather_new_missions():
    print("test")
    # do stuff here
     async with aiohttp.ClientSession() as session:
          url = "example.com"
          async with session.get(url) as resp:
              if resp.status == 200:
                  f = await aiofiles.open(filename, mode="wb")
                  await f.write(await resp.read())
                  await f.close()

So this code wouldn't even print "test" because of aiohttp way of implementing a loop ?
I don't quite understand how the code you've linked above could help me here.

@gawel
Copy link
Owner

gawel commented Nov 2, 2022

Yeah it's hard to help here. I'm trying. But I have no other clue

Everything seems to work with 3.10 so the problem should be on your side. Related to your code or a third-party library

https://github.com/gawel/aiocron/actions/runs/3376501956/jobs/5604299015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants