Skip to content

Fixed task output stream#22

Merged
matllubos merged 1 commit intomasterfrom
FixTasksOutputStream
Sep 20, 2019
Merged

Fixed task output stream#22
matllubos merged 1 commit intomasterfrom
FixTasksOutputStream

Conversation

@matllubos
Copy link
Collaborator

No description provided.

@matllubos matllubos force-pushed the FixTasksOutputStream branch 4 times, most recently from b26e22f to 9e2ba75 Compare September 19, 2019 16:30
bind=True,
name='sum_task')
def sum_task(self, task_id, a, b):
def sum_task(self, a, b):
Copy link
Collaborator Author

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

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(''))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

posunul jsme django

import json
from json import JSONDecodeError

from datetime import timedelta
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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 __call__(self, *args, **kwargs):
# Every set attr is send here
self.request.output_stream = StringIO()
Copy link
Collaborator Author

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


def on_success(self, retval, task_id, args, kwargs):
if retval:
self.request.output_stream.write('Return value is "{}"'.format(retval))
Copy link
Collaborator Author

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

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)
Copy link
Collaborator Author

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

@matllubos matllubos merged commit 9305703 into master Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant