Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cache backend to thread local storage instead of global variable * Cache oid to thread local storage instead of global variable * Improve code returning thread_local data * Move thread local storage to Celery class, introduced thread_oid and added unittests
- Loading branch information
Showing
8 changed files
with
159 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import uuid | ||
|
||
|
||
class test_Canvas: | ||
|
||
def test_freeze_reply_to(self): | ||
# Tests that Canvas.freeze() correctly | ||
# creates reply_to option | ||
|
||
@self.app.task | ||
def test_task(a, b): | ||
return | ||
|
||
s = test_task.s(2, 2) | ||
s.freeze() | ||
|
||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
def foo(): | ||
s = test_task.s(2, 2) | ||
s.freeze() | ||
return self.app.thread_oid, s.options['reply_to'] | ||
with ThreadPoolExecutor(max_workers=1) as executor: | ||
future = executor.submit(foo) | ||
t_reply_to_app, t_reply_to_opt = future.result() | ||
|
||
assert uuid.UUID(s.options['reply_to']) | ||
assert uuid.UUID(t_reply_to_opt) | ||
# reply_to must be equal to thread_oid of Application | ||
assert self.app.thread_oid == s.options['reply_to'] | ||
assert t_reply_to_app == t_reply_to_opt | ||
# reply_to must be thread-relative. | ||
assert t_reply_to_opt != s.options['reply_to'] |