Created
December 15, 2023 14:15
-
-
Save bstiel/a9c1951d28b01a99579c11ad76ded3d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker: celery --app=worker.app worker --pool=gevent --concurrency=10 --loglevel=INFO | |
producer: python producer.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from worker import app | |
def main(): | |
while True: | |
time.sleep(2) | |
app.send_task("sleep") | |
if __name__ == "__main__": | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import Celery | |
import time | |
import inspect | |
app = Celery( | |
"worker", | |
broker="redis://localhost:6370/0", | |
broker_connection_retry_on_startup=True, | |
broker_connection_retry=True, | |
) | |
@app.task(name="sleep") | |
def sleep(): | |
print(inspect.getmodule(time.sleep)) | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment