osbot-utils 1.46.0__py3-none-any.whl → 1.48.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- osbot_utils/utils/Threads.py +20 -1
- osbot_utils/utils/Toml.py +1 -1
- osbot_utils/version +1 -1
- {osbot_utils-1.46.0.dist-info → osbot_utils-1.48.0.dist-info}/METADATA +2 -2
- {osbot_utils-1.46.0.dist-info → osbot_utils-1.48.0.dist-info}/RECORD +7 -7
- {osbot_utils-1.46.0.dist-info → osbot_utils-1.48.0.dist-info}/LICENSE +0 -0
- {osbot_utils-1.46.0.dist-info → osbot_utils-1.48.0.dist-info}/WHEEL +0 -0
osbot_utils/utils/Threads.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import asyncio
|
2
2
|
import logging
|
3
3
|
import typing
|
4
|
+
from concurrent.futures import ThreadPoolExecutor
|
4
5
|
|
5
6
|
def invoke_async_function(target: typing.Coroutine):
|
6
7
|
"""Run an asynchronous coroutine in a new event loop."""
|
@@ -24,4 +25,22 @@ def invoke_async_function(target: typing.Coroutine):
|
|
24
25
|
else:
|
25
26
|
asyncio.set_event_loop(None)
|
26
27
|
|
27
|
-
logger.level = level_original # restore the original log level
|
28
|
+
logger.level = level_original # restore the original log level
|
29
|
+
|
30
|
+
|
31
|
+
def invoke_in_new_event_loop(target: typing.Coroutine): # Runs a coroutine in a new event loop in a separate thread and returns the result
|
32
|
+
def run_in_new_loop(): # Function to run the coroutine in a new event loop
|
33
|
+
new_loop = asyncio.new_event_loop() # Create a new event loop
|
34
|
+
asyncio.set_event_loop(new_loop) # Set the new event loop as the current event loop
|
35
|
+
try:
|
36
|
+
return new_loop.run_until_complete(target) # Run the coroutine in the new event loop
|
37
|
+
finally:
|
38
|
+
new_loop.close() # Close the event loop to free resources
|
39
|
+
|
40
|
+
with ThreadPoolExecutor() as pool: # Create a thread pool executor
|
41
|
+
future = pool.submit(run_in_new_loop) # Submit the function to run in the thread pool
|
42
|
+
result = future.result() # Wait for the result of the future
|
43
|
+
return result # Return the result from the coroutine
|
44
|
+
|
45
|
+
async_invoke_in_new_loop = invoke_in_new_event_loop
|
46
|
+
invoke_async = invoke_async_function # todo: see if this is best use of this function name
|
osbot_utils/utils/Toml.py
CHANGED
osbot_utils/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v1.
|
1
|
+
v1.48.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.48.0
|
4
4
|
Summary: OWASP Security Bot - Utils
|
5
5
|
Home-page: https://github.com/owasp-sbot/OSBot-Utils
|
6
6
|
License: MIT
|
@@ -22,7 +22,7 @@ Description-Content-Type: text/markdown
|
|
22
22
|
|
23
23
|
Powerful Python util methods and classes that simplify common apis and tasks.
|
24
24
|
|
25
|
-

|
26
26
|
[](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
|
27
27
|
|
28
28
|
|
@@ -292,13 +292,13 @@ osbot_utils/utils/Python_Logger.py,sha256=tx8N6wRKL3RDHboDRKZn8SirSJdSAE9cACyJkx
|
|
292
292
|
osbot_utils/utils/Regex.py,sha256=0ubgp8HKsS3PNe2H6XlzMIcUuV7jhga3VkQVDNOJWuA,866
|
293
293
|
osbot_utils/utils/Status.py,sha256=Yq4s0TelXgn0i2QjCP9V8mP30GabXp_UL-jjM6Iwiw4,4305
|
294
294
|
osbot_utils/utils/Str.py,sha256=kxdY8ROX4FdJtCaMTfOc8fK_xcDICprNkefHu2MMNU4,2585
|
295
|
-
osbot_utils/utils/Threads.py,sha256=
|
296
|
-
osbot_utils/utils/Toml.py,sha256=
|
295
|
+
osbot_utils/utils/Threads.py,sha256=bClwSZ1T_A92o4LRiNwIN2rn5oKfPLupqzy4ozdPdNw,2297
|
296
|
+
osbot_utils/utils/Toml.py,sha256=SD6IA4-mrtoBXcI0dIGKV9POMQNd6WYKvmDQq7GQ6ZQ,1438
|
297
297
|
osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
|
298
298
|
osbot_utils/utils/Zip.py,sha256=G6Hk_hDcm9yvWzhTKzhT0R_6f0NBIAchHqMxGb3kfh4,14037
|
299
299
|
osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
300
|
-
osbot_utils/version,sha256=
|
301
|
-
osbot_utils-1.
|
302
|
-
osbot_utils-1.
|
303
|
-
osbot_utils-1.
|
304
|
-
osbot_utils-1.
|
300
|
+
osbot_utils/version,sha256=JsJP7WaornLYr7vvK7_49I4Wp8WPCrP0NyymiaWWpo8,8
|
301
|
+
osbot_utils-1.48.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
302
|
+
osbot_utils-1.48.0.dist-info/METADATA,sha256=kOiwLvKz80E0wYnMTficj6h8wQBQliYBLvDZ81X7WeM,1266
|
303
|
+
osbot_utils-1.48.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
304
|
+
osbot_utils-1.48.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|