-
-
Save jpic/1205966 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
| >>> rm -rf '/srv/bet.yourlabs.org/main/var/test-tasks/*' && uwsgi --ini uwsgi.ini | |
| [uWSGI] getting INI configuration from uwsgi.ini | |
| *** Starting uWSGI 1.0-dev-1488 (32bit) on [Fri Sep 9 11:14:11 2011] *** | |
| compiled with version: 4.6.0 20110513 (prerelease) on 09 September 2011 10:11:57 | |
| detected binary path: /srv/bet.yourlabs.org/bet_env/bin/uwsgi | |
| uWSGI running as root, you can use --uid/--gid/--chroot options | |
| *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** | |
| your memory page size is 4096 bytes | |
| spawned uWSGI http 1 (pid: 16796) | |
| HTTP router/proxy bound on 0.0.0.0:7000 | |
| uwsgi socket 0 bound to TCP address 127.0.0.1:40982 (port auto-assigned) fd 3 | |
| Python version: 2.7.1 (r271:86832, Feb 21 2011, 01:26:25) [GCC 4.5.2 20110127 (prerelease)] | |
| Set PythonHome to /srv/bet.yourlabs.org/env | |
| Python main interpreter initialized at 0x9d130a8 | |
| your server socket listen backlog is limited to 100 connections | |
| *** Operational MODE: single process *** | |
| added /srv/bet.yourlabs.org/main/ to pythonpath. | |
| added /srv/bet.yourlabs.org/main/apps/ to pythonpath. | |
| written 72 bytes to spool file /srv/bet.yourlabs.org/main/var/test-tasks/uwsgi_spoolfile_on_tina_16795_1_0_1315559651_745596 | |
| WSGI application 0 (mountpoint=) ready on interpreter 0x9d130a8 pid: 16795 (default app) | |
| *** uWSGI is running in multiple interpreter mode *** | |
| spawned uWSGI master process (pid: 16795) | |
| spawned the uWSGI spooler on dir /srv/bet.yourlabs.org/main/var/test-tasks with pid 16797 | |
| spawned uWSGI worker 1 (pid: 16798, cores: 1) | |
| INFO imported | |
| managing spool request uwsgi_spoolfile_on_tina_16795_1_0_1315559651_745596 ... | |
| done with task/spool uwsgi_spoolfile_on_tina_16795_1_0_1315559651_745596 after 0 seconds |
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
| import logging | |
| import time | |
| import uwsgi | |
| from django.core.management import call_command | |
| from tasksconsumer import * | |
| from gsm.management.commands.gsm_sync import Command as GsmSyncCommand | |
| logger = logging.getLogger('gsm') | |
| logger.info('imported') | |
| @queueconsumer('gsm_sync') | |
| def gsm_sync(args={}): | |
| logger.info('started gsm_sync function') | |
| cooldowns = (1,2,3,4) | |
| attempt = 0 | |
| while attempt <= len(cooldowns): | |
| e = None | |
| try: | |
| logger.info('started gsm_sync actual task') | |
| raise Exception() | |
| except Exception as e: | |
| logger.info("Caught %s while doing gsm_sync for the %s th time, sleep %s seconds and retry" % (e, attempt, cooldowns[attempt])) | |
| time.sleep(cooldowns[attempt]) | |
| attempt += 1 | |
| if e is not None: | |
| logger.error('Failed %s times' % len(cooldowns)) | |
| # notify admins... | |
| enqueue(queue='gsm_sync') | |
| logger.info('enqueued self again') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment