Conversation
b26e22f to
9e2ba75
Compare
9e2ba75 to
1641eb3
Compare
| bind=True, | ||
| name='sum_task') | ||
| def sum_task(self, task_id, a, b): | ||
| def sum_task(self, a, b): |
There was a problem hiding this comment.
task_id už není nutné přenášet, dá se získat z self.request.id, to je objekt, který drží kontext k danému tasku
| input_logged_request = InputLoggedRequest.objects.get() | ||
| assert_equal(len(input_logged_request.request_body), 10) | ||
| assert_true(input_logged_request.request_body.endswith('...')) | ||
| assert_true(input_logged_request.request_body.endswith('…')) |
There was a problem hiding this comment.
posunul jsme django
| import json | ||
| from json import JSONDecodeError | ||
|
|
||
| from datetime import timedelta |
There was a problem hiding this comment.
chybička se vloudila
| output_stream = self.request.output_stream | ||
| super().push_request(*args, **kwargs) | ||
| self.request.id = task_id | ||
| self.request.output_stream = output_stream |
There was a problem hiding this comment.
tohle je velká sranda, dělá to jen když je zapnuto CELERY_ALWAYS_EAGER. Prostě přes spuštěním commandu to přepíše context a odstraní i task_id což dost dobře nechápu proč to je takto blbě napsané. Nicméně já si to tam prostě vrátil zpět
|
|
||
| def __call__(self, *args, **kwargs): | ||
| # Every set attr is send here | ||
| self.request.output_stream = StringIO() |
There was a problem hiding this comment.
před zavoláním commandu si tam přidáme stream
|
|
||
| def on_success(self, retval, task_id, args, kwargs): | ||
| if retval: | ||
| self.request.output_stream.write('Return value is "{}"'.format(retval)) |
There was a problem hiding this comment.
pokud task vrátí nějakou hodnotu tak to dáme do výpisu
| kwargs={**kwargs, 'attempt': attempt+1}, | ||
| countdown=self.repeat_timeouts[attempt - 1] * 60, | ||
| queue=self.queue | ||
| queue=queue or getattr(self, 'queue', settings.CELERY_DEFAULT_QUEUE) |
There was a problem hiding this comment.
tady jsem fixnul nastavení fronty, jde jí nyní i změnit
No description provided.