-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed task output stream #22
Conversation
b26e22f
to
9e2ba75
Compare
9e2ba75
to
1641eb3
Compare
@@ -7,13 +7,13 @@ | |||
base=LoggedTask, | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -83,28 +83,28 @@ def test_request_body_should_be_truncated(self): | |||
self.post('/admin/login/', data={'username': 20 * 'a', 'password': 20 * 'b'}) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
posunul jsme django
@@ -2,6 +2,8 @@ | |||
import json | |||
from json import JSONDecodeError | |||
|
|||
from datetime import timedelta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 get_task(self, task_id): | ||
return CeleryTaskLog.objects.get(pk=task_id) | ||
|
||
def __call__(self, *args, **kwargs): | ||
# Every set attr is send here | ||
self.request.output_stream = StringIO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
před zavoláním commandu si tam přidáme stream
@@ -62,10 +58,13 @@ def on_start(self, task_id, args, kwargs): | |||
self._call_callback('start', task_id, args, kwargs) | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pokud task vrátí nějakou hodnotu tak to dáme do výpisu
@@ -126,7 +120,7 @@ def log_and_retry(self, attempt, exception_message=None, *args, **kwargs): | |||
args=args, | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tady jsem fixnul nastavení fronty, jde jí nyní i změnit
No description provided.