File tree Expand file tree Collapse file tree
tutorial-redis/python-celery Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ "use strict" ;
2+ const celery = require ( "../../dist" ) ;
3+
4+ const client = celery . createClient ( "redis://" , "redis://" ) ;
5+ // client.conf.TASK_PROTOCOL = 1;
6+
7+ const task = client . createTask ( "delay_job" ) ;
8+
9+ async function main ( ) {
10+ const result = task . applyAsync ( ) ;
11+ const data = await result . get ( ) ;
12+ console . log ( data ) ;
13+ await client . disconnect ( ) ;
14+ }
15+
16+ main ( ) ;
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+ const celery = require ( '../../dist' ) ;
3+ const worker = celery . createWorker ( "redis://" , "redis://" ) ;
4+
5+ worker . register ( "delay_job" , async ( ) => {
6+ const delayTime = 1000 ;
7+
8+ await new Promise ( ( resolve , reject ) => {
9+ setTimeout ( resolve , delayTime ) ;
10+ } )
11+ return {
12+ delayTime
13+ }
14+ } ) ;
15+ worker . start ( ) ;
Original file line number Diff line number Diff line change 1+ celery worker -A tasks --loglevel=INFO
Original file line number Diff line number Diff line change 1+ celery worker -A tasks --loglevel=INFO
You can’t perform that action at this time.
0 commit comments