This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Make log send async #1174
Merged
Merged
Make log send async #1174
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
16cd7e6
Make log send async
6c4748a
Update CHANGELOG
c165af7
Merge remote-tracking branch 'origin/main' into ps-fideslog-loop-error
7fea388
Add async to additional fideslog calls
5f6f626
WIP
1f971b7
Fix issue with async function is celery
a5c6a45
Merge remote-tracking branch 'origin/main' into ps-fideslog-loop-error
368986a
Make __send work with name mangling
35a8526
Remove extra await
21b9dd6
Await coroutines in tests
6babd92
Remove analytics id
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,17 @@ | ||
import asyncio | ||
from functools import wraps | ||
from typing import Any, Callable | ||
|
||
|
||
def sync(func: Callable) -> Any: | ||
"""Converts an async function into a sync function.""" | ||
|
||
@wraps(func) | ||
def wrap(*args: Any, **kwargs: Any) -> Any: | ||
try: | ||
loop = asyncio.get_running_loop() | ||
return loop.run_until_complete(func(*args, **kwargs)) | ||
except RuntimeError: | ||
return asyncio.run(func(*args, **kwargs)) | ||
|
||
return wrap |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# pylint: disable=unused-wildcard-import, wildcard-import | ||
|
||
import asyncio | ||
import json | ||
import logging | ||
from typing import Any, Callable, Dict, Generator, List | ||
|
@@ -250,3 +251,13 @@ def subject_identity_verification_not_required(): | |
config.execution.subject_identity_verification_required = False | ||
yield | ||
config.execution.subject_identity_verification_required = original_value | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def event_loop(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you explain why this is needed specifically for tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It happens to be the same issue we are solving with the async log. When running the async tests it will sometimes start up multiple event loops and cause errors. I have found that using this fixture in my other async code bases has prevent the error. |
||
try: | ||
loop = asyncio.get_running_loop() | ||
except RuntimeError: | ||
loop = asyncio.new_event_loop() | ||
yield loop | ||
loop.close() |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
oh nice workaround!