-
Notifications
You must be signed in to change notification settings - Fork 2
Python 3.13 support: wrapping update #359
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
Closed
Closed
Changes from 56 commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
5b47fc8
Create new process worker script and run it on context creation
bitterpanda63 6aa778b
Remove INITIALIZE_ROUTE command
bitterpanda63 ead26f8
Cleanup of process_worker logic
bitterpanda63 932d840
Create a process_worker and process_worker_loader in thread
bitterpanda63 c10d834
make thread_cache process-llocal
bitterpanda63 312c115
Improve route increment stuff
bitterpanda63 a1f9a25
fix thread_cache_test test cases
bitterpanda63 a74b346
Fix all test cases that relied on internal thread cache logic
bitterpanda63 2f08b88
Cleanup thread_cache.py
bitterpanda63 950849c
make log message make some sense
bitterpanda63 436f630
fix thread_cache res check and only start process_worker with context
bitterpanda63 f6d6cfc
Fix broken routes test
bitterpanda63 3f570f3
Fix django mysql e2e test
bitterpanda63 f41512e
Also add apispec to e2e test
bitterpanda63 19c7b62
Total is 3 requests for django_mysql e2e
bitterpanda63 5b83da4
Fix request_handler
bitterpanda63 0c929cc
Fix test cases of request_handler
bitterpanda63 05a87f5
Fix request_handler and it's test cases
bitterpanda63 4ddd294
Fix broken test case for vulnerability scanner
bitterpanda63 c43ab2f
validate the firewall lists API response correctly
bitterpanda63 645e303
Merge remote-tracking branch 'origin/fix/validate-firewall-lists-corr…
bitterpanda63 61c9ae9
Merge branch 'main' into improve-thread-caching-separated
bitterpanda63 3d228bb
Merge branch 'main' into improve-thread-caching-separated
bitterpanda63 960212f
Merge remote-tracking branch 'origin/main' into improve-thread-cachin…
bitterpanda63 5782587
Improves heartbeat event validation
bitterpanda63 d3225ba
Merge remote-tracking branch 'origin/main' into improve-thread-cachin…
bitterpanda63 b08726d
Merge branch 'main' into improve-thread-caching-separated
bitterpanda63 116d7b2
Test 3.13 as well for unit tests and e2e tests
bitterpanda63 9d9ad25
Benchmarks for all supported python versions
bitterpanda63 72cd57d
init tests as a module
bitterpanda63 8336b97
Refactor pymysql to use wrapt
bitterpanda63 dde3ba9
(poetry) install wrapt
bitterpanda63 47058fd
Update subprocess patching
bitterpanda63 32034d4
pymysql patches change order
bitterpanda63 7dc0a6f
move back to bottom, python order for pymysql, subprocess
bitterpanda63 e16b8ed
convert os_system patch
bitterpanda63 15a28eb
pymongo convert code to wrapt code
bitterpanda63 23e5fcf
convert mysqlclient
bitterpanda63 76894de
convert io module
bitterpanda63 afe9b77
Convert shutil module
bitterpanda63 142770d
Convert asyncpg module
bitterpanda63 fb309e7
Convert builtins.py
bitterpanda63 91ca20d
define new standards for the wrapping
bitterpanda63 dd9b4b0
update existing modules
bitterpanda63 9d37dc9
Update io module to use new system
bitterpanda63 1dab0f2
Update both builtins.py and asyncpg.py to use the new patching system
bitterpanda63 cffd729
Cleanup checks for builtins and shutil
bitterpanda63 0196b11
linting for asyncpg.py
bitterpanda63 6a9711d
Cleanup the patching module
bitterpanda63 57faa80
Convert os.py
bitterpanda63 e8c50d3
Update http_client.py sink, adding the @after
bitterpanda63 87892fd
Update psycopg sink
bitterpanda63 fa9f54f
convert socket.py to new format
bitterpanda63 cb37a0c
Fix shutil and shutil test cases
bitterpanda63 06e7abd
Convert psycopg2 module
bitterpanda63 6af31a4
update sample app lockfiles
bitterpanda63 7834861
Update actions/setup-python v2 -> v5
bitterpanda63 70305bf
Fix @after by removing finally: which was swallowing the error
bitterpanda63 35c4c82
Fix broken subprocess test cases
bitterpanda63 3618197
Remove ms checks for starlette benchmark in favour of percentages
bitterpanda63 31705c1
Exclude psycopg2 testing for python 3.13
bitterpanda63 3aa49cc
Make sure psycopg2.py implementation is the same as prev one
bitterpanda63 807b981
Add extra tests for psycopg2 and fix issue for immutables
bitterpanda63 b8eec8f
use assert_any_call for python 3.13
bitterpanda63 0aabc2c
Patch os.path.realpath for python 3.13
bitterpanda63 b29cc3e
Patch os.path.realpath for python 3.13
bitterpanda63 5a2037c
Merge remote-tracking branch 'origin/python-3.13-support' into python…
bitterpanda63 f77ec4a
Merge branch 'main' into python-3.13-support
bitterpanda63 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
11 changes: 0 additions & 11 deletions
11
aikido_zen/background_process/commands/initialize_route.py
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
aikido_zen/background_process/commands/initialize_route_test.py
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,70 @@ | ||
from wrapt import wrap_object, FunctionWrapper, when_imported | ||
from aikido_zen.background_process.packages import ANY_VERSION, is_package_compatible | ||
from aikido_zen.errors import AikidoException | ||
from aikido_zen.helpers.logging import logger | ||
|
||
|
||
def on_import(name, package="", version_requirement=ANY_VERSION): | ||
""" | ||
Decorator to register a function to be called when a package is imported. | ||
It checks if the package is compatible with the specified version requirement. | ||
""" | ||
|
||
def decorator(func): | ||
if package and not is_package_compatible(package, version_requirement): | ||
return | ||
|
||
when_imported(name)(func) # Register the function to be called on import | ||
|
||
return decorator | ||
|
||
|
||
def patch_function(module, name, wrapper): | ||
""" | ||
Patches a function in the specified module with a wrapper function. | ||
""" | ||
try: | ||
wrap_object(module, name, FunctionWrapper, (wrapper,)) | ||
except Exception as e: | ||
logger.info("Failed to wrap %s:%s, due to: %s", module, name, e) | ||
|
||
|
||
def before(wrapper): | ||
""" | ||
Surrounds a patch with try-except and calls the original function at the end | ||
""" | ||
|
||
def decorator(func, instance, args, kwargs): | ||
try: | ||
wrapper(func, instance, args, kwargs) # Call the patch | ||
except AikidoException as e: | ||
raise e # Re-raise AikidoException | ||
except Exception as e: | ||
logger.debug( | ||
"%s:%s wrapping-before error: %s", func.__module__, func.__name__, e | ||
) | ||
|
||
return func(*args, **kwargs) # Call the original function | ||
|
||
return decorator | ||
|
||
|
||
def after(wrapper): | ||
""" | ||
Surrounds a patch with try-except, calls the original function and gives the return value to the patch | ||
""" | ||
|
||
def decorator(func, instance, args, kwargs): | ||
return_value = func(*args, **kwargs) # Call the original function | ||
try: | ||
wrapper(func, instance, args, kwargs, return_value) # Call the patch | ||
except AikidoException as e: | ||
raise e # Re-raise AikidoException | ||
except Exception as e: | ||
logger.debug( | ||
"%s:%s wrapping-after error: %s", func.__module__, func.__name__, e | ||
) | ||
finally: | ||
return return_value | ||
|
||
return decorator |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.