-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add LocalQueue and local pool, refactor semaphores
- Loading branch information
Showing
34 changed files
with
517 additions
and
291 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 was deleted.
Oops, something went wrong.
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
Empty file.
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,73 @@ | ||
import time | ||
|
||
import pytest | ||
|
||
from zetta_utils.message_queues.file.queue import FileQueue | ||
|
||
|
||
def success_fn(): | ||
return "Success" | ||
|
||
|
||
def test_make_and_delete_file_queue(): | ||
with FileQueue("test_queue"): | ||
pass | ||
|
||
|
||
def test_get_tq_queue(): | ||
with FileQueue("test_queue"): | ||
FileQueue("test_queue")._get_tq_queue() # pylint:disable = protected-access | ||
|
||
|
||
def test_push_pull(): | ||
with FileQueue("test_queue") as q: | ||
payloads = {None, 1, "asdfadsfdsa", success_fn} | ||
q.push(list(payloads)) | ||
time.sleep(0.1) | ||
result = q.pull(max_num=len(payloads)) | ||
assert len(result) == len(payloads) | ||
received_payloads = {r.payload for r in result} | ||
assert received_payloads == payloads | ||
|
||
|
||
def test_delete(): | ||
with FileQueue("test_queue") as q: | ||
q.push([None]) | ||
time.sleep(0.1) | ||
result = q.pull(max_num=10) | ||
assert len(result) == 1 | ||
result[0].acknowledge_fn() | ||
time.sleep(1.1) | ||
result_empty = q.pull() | ||
assert len(result_empty) == 0 | ||
|
||
|
||
def test_extend_lease(): | ||
with FileQueue("test_queue") as q: | ||
q.push([None]) | ||
time.sleep(0.1) | ||
result = q.pull() | ||
assert len(result) == 1 | ||
result[0].extend_lease_fn(3) | ||
time.sleep(1) | ||
result_empty = q.pull() | ||
assert len(result_empty) == 0 | ||
time.sleep(2.1) | ||
result_nonempty = q.pull() | ||
assert len(result_nonempty) == 1 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"queue_name", ["fq://test_queue", "file://test_queue", "sqs://test_queue"] | ||
) | ||
def test_prefix_exc(queue_name): | ||
with pytest.raises(ValueError): | ||
with FileQueue(queue_name): | ||
pass | ||
|
||
|
||
def test_double_init_exc(): | ||
with pytest.raises(RuntimeError): | ||
with FileQueue("test_queue"): | ||
with FileQueue("test_queue"): | ||
pass |
Empty file.
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.