Code Monkey home page Code Monkey logo

aioscheduler's Introduction

Gelbpunkt's github stats

Who I am

I am a semi-adult coder who's started many years ago with Python, later got into JavaScript, HTML and CSS and eventually learnt Rust, TypeScript and Kotlin. Nowadays I mainly use Rust and Python and do everything from VueJS frontends to parsers and LLVM codegen to scaling Discord bots to a new level or writing Python extensions with pyo3 and Rust.

What I use

Apart from the aforementioned languages, I am a container freak and use podman for everything I deploy. I use Fedora on daily desktop, Raspberry Pi and servers. I do love Alpine just as much, though.

What I write

Instead of linking stuff here, just check my repos. Some are more, some less interesting and you might find them useful.

Feel free to mail me if you want to contact me or got questions!

aioscheduler's People

Contributors

gelbpunkt avatar starspritechippy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aioscheduler's Issues

CRITICAL! Tasks scheduled in TimedScheduler remain in event loop forever

This problem appears only when using TimedScheduler.

After tasks have been executed they stay in event loop till the end of program, which can be critical for overall perfomance.

Here is minimal code to reproduce that bug:

async def task(num):
    print(f'Num: {num}')

async def main():
    scheduler = aioscheduler.TimedScheduler(10)

    for i in range(10):
        scheduler.schedule(task(i), datetime.datetime.utcnow() + datetime.timedelta(seconds=i + 3))

    scheduler.start()

    while True:
        print(len(asyncio.all_tasks()))  # Getting count of currently running tasks in main event loop
        await asyncio.sleep(1)

asyncio.run(main())

Expected behavior
Here is a code example without scheduler, using only asyncio.create_task function:

async def task(num):
    await asyncio.sleep(num)
    print(f'Num: {num}')

async def main():

    for i in range(10):
        asyncio.create_task(task(i))

    while True:
        print(len(asyncio.all_tasks()))
        await asyncio.sleep(1)

asyncio.run(main())

At first it shows 11 active tasks (1 for main function and 10 for custom tasks I added). But gradually as tasks run this number decreases back to 1.

This is not the case for aioscheduler scheduler where tasks somewhy remain active even after function finishes.

Library and Python version

  • Library: 1.4.2 (latest)
  • Python: 3.10.6

I'll try to fix this bug myself and create pull request, but in any case this bug should be fixed ASAP

Don't work in case of function in different class

So I have a function in my bot class which a subclass of AutoShardedBot and the function is remove_role_task

When I try to start a job from a cog using schedule method and the coro is like bot.remove_role_task the task never starts. And when I check the tasks of the scheduler its empty. But when I create the same method in the cog itself the task starts and executes in time.

Both examples does not work in Python3.11, But works in Python3.10

I have been using this library for a long time but looks like it does not work in Python3.11, tasks are never executed. And no error is also printed on the console

but when I stop the application it just says x is never awaited error.

Just use the example on Readme. It will not work on 3.11 but work on 3.10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.