Skip to content

Instantly share code, notes, and snippets.

@neoblackcap
Last active April 28, 2022 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neoblackcap/98c98b3ea66553cdf77976c4f7f7b6d2 to your computer and use it in GitHub Desktop.
Save neoblackcap/98c98b3ea66553cdf77976c4f7f7b6d2 to your computer and use it in GitHub Desktop.
// tasks.py
import asyncio
import celery
app = celery.Celery('app')
async def coroutine():
await asyncio.sleep(5)
print("pass 5 second")
@app.task
def simple_task():
loop = asyncio.get_event_loop()
loop.run_until_complete(coroutine())
// sample.py
from . import tasks
if __name__ == '__main__':
tasks.simple_task.apply_async()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment