No project description provided
Project description
Rustex
Context Aware Async Mutex
Example
import asyncio
import random
import contextvars
import uuid
import rustex
mutex = rustex.Rustex()
cv = contextvars.ContextVar('rustex')
class PyRustexContext:
def __init__(self):
self.ctx = str(uuid.uuid4())
def __enter__(self):
cv.set(self.ctx)
mutex.add_context(self.ctx)
return self
def __exit__(self, type, value, traceback):
mutex.remove_context(self.ctx)
cv.set(None)
class PyRustexMutex:
def __init__(self, name: str):
self.name = name
async def __aenter__(self):
await mutex.acquire_mutex(self.name, cv.get())
return self
async def __aexit__(self, type, value, traceback):
await mutex.release_mutex(self.name, cv.get())
def with_rustex(name: str) -> PyRustexMutex:
return PyRustexMutex(name)
async def a_main():
async def drama(i):
mt = 'test{}'.format(random.randint(0, 3))
try:
with PyRustexContext():
async with with_rustex(mt):
print("In a_main in context {} on mtex {}".format(cv.get(), mt))
if random.random() < .5:
raise ArithmeticError("Dramatic Test Exception")
print("Survived mtex {}".format(mt))
except ArithmeticError as e:
print("Past exception mtex {}".format(mt))
pass
await asyncio.gather(*[drama(i) for i in range(10)])
def main():
try:
loop = asyncio.new_event_loop()
loop.run_until_complete(a_main())
loop.close()
except Exception as e:
print(e)
if __name__ == "__main__":
main()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rustex-0.2.1.tar.gz.
File metadata
- Download URL: rustex-0.2.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9bab25c77362ddcb1d5218d4fbfea893486fc5669f001022f6b9397cb121564
|
|
| MD5 |
9c882291bc8af1fbc77c860b4353c97c
|
|
| BLAKE2b-256 |
82ee9770899cb3c3cf251e3dfa576bde081e025b34eb7dbb9190eae42652dd3e
|
File details
Details for the file rustex-0.2.1-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.
File metadata
- Download URL: rustex-0.2.1-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: PyPy, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6d0daa5f814109f32bfebd07ddc4d1bda734ddbb5d37fb2d36cebf515c7d9d1
|
|
| MD5 |
95a1bd4a051c4f67df55888330f6cd6f
|
|
| BLAKE2b-256 |
c309731e314c60cdf7150743df936d7aa2522cb0b73def68c9dd7ba37dd00c9c
|
File details
Details for the file rustex-0.2.1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.
File metadata
- Download URL: rustex-0.2.1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: PyPy, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
909a58d874b58aa56375c10b97986cc636df3f9d5cea18f5f596023b0bce44c8
|
|
| MD5 |
cb95440808e68b2e82c2909d92bf9c84
|
|
| BLAKE2b-256 |
560efb9528dac137507ced0436af6e5a2182f97a78c385edbe60e2e89db4413f
|
File details
Details for the file rustex-0.2.1-cp310-none-win_amd64.whl.
File metadata
- Download URL: rustex-0.2.1-cp310-none-win_amd64.whl
- Upload date:
- Size: 297.8 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
022db42ba6b59260e56bdbd53093ceee9081bc2aeebf5ebe34a894d9efc7e0ab
|
|
| MD5 |
d035bc95a452dc126921cb6b9f003c94
|
|
| BLAKE2b-256 |
5b76f310944e2a45c55e570182bc2d7b805c0fabb49b90af1248ea4abddb5b1e
|
File details
Details for the file rustex-0.2.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.
File metadata
- Download URL: rustex-0.2.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e2900ca46b5b8ae4ac73b29ddb0f2fa432a1e41ac1cb06e790b1211666c75a2
|
|
| MD5 |
b63f1bf2b73910de107815f4768d3f8f
|
|
| BLAKE2b-256 |
987784c5d07d90330adad01e646978f7f21e1283099d97c69c7134bf722c8398
|
File details
Details for the file rustex-0.2.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.
File metadata
- Download URL: rustex-0.2.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 868.3 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3ebc89817729f9a18472469a15327e98adf0d95645ee849f65ed6602728961d
|
|
| MD5 |
90ecb28252cc9b9638f1d3e408694a0f
|
|
| BLAKE2b-256 |
4fabef0dcd697fa4fb9ff86256b5f0996ebf02617cbe4c77aef52ce42a50d71d
|
File details
Details for the file rustex-0.2.1-cp39-none-win_amd64.whl.
File metadata
- Download URL: rustex-0.2.1-cp39-none-win_amd64.whl
- Upload date:
- Size: 298.0 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2be1850219a8809bf29b326f8f46835dd4f5dd3f5e93f9048f17bd8f49c57493
|
|
| MD5 |
fd0d9167de4d23f82c58670e3bf682b6
|
|
| BLAKE2b-256 |
88ff9ea183598f83e3ec7db6c88da1d5c57adbba05d764a03d7512d19b3fa947
|
File details
Details for the file rustex-0.2.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.
File metadata
- Download URL: rustex-0.2.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52d1dd3a3af8c4ad4cb8ee5e17bb4ed64d772229113d5a35a0fade7ab0137b86
|
|
| MD5 |
e64f60e656feb8123434ae509c034965
|
|
| BLAKE2b-256 |
16e12409ab251f268c9679014945a4e39d250ccd1e6a50f48925d2b2079abf24
|
File details
Details for the file rustex-0.2.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.
File metadata
- Download URL: rustex-0.2.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 868.6 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a36d39873f3b63019b5cdaab787b3f189d73d5840d9e5c9421f750831a62b95
|
|
| MD5 |
d10dc0295545ee7747a306d05e6a6dcb
|
|
| BLAKE2b-256 |
5d0f19ceee9d7d42cc111ed00aa25232ae5780fe4129a0332acfe15520b268f9
|
File details
Details for the file rustex-0.2.1-cp38-none-win_amd64.whl.
File metadata
- Download URL: rustex-0.2.1-cp38-none-win_amd64.whl
- Upload date:
- Size: 298.4 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0248288a0e7d81dab2590c21a401bc7a9f536979c041b1d6ee392755440a50a
|
|
| MD5 |
e64004ce9bfc6ad97084abab60769eae
|
|
| BLAKE2b-256 |
8c2e22518fcab494540f534f403977104f40bd7505770eca49c3930a4b2175b8
|
File details
Details for the file rustex-0.2.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.
File metadata
- Download URL: rustex-0.2.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b8e593faba91411a3ee3ba3005fcbed73647955d500b9ef7b196adda34fe05d
|
|
| MD5 |
f4598cdc6b9d4ed02b8cc726c67b0ab8
|
|
| BLAKE2b-256 |
9dd11dd10980fc7125dc979137cf3ff858bf4ae09d4e2fbc2bbdd2841f588dd1
|
File details
Details for the file rustex-0.2.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.
File metadata
- Download URL: rustex-0.2.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 868.3 kB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37182b0991925884f8e9a1a3ad11ba16d86cab1ff694ab0d540bdae34617edeb
|
|
| MD5 |
8e2229ac06255ad459e8fe8e3420ead2
|
|
| BLAKE2b-256 |
2c2a14e4bc87a39b6503f99f293a0a1ab5101f0fa7d73476af6fdfade7e03a15
|
File details
Details for the file rustex-0.2.1-cp37-none-win_amd64.whl.
File metadata
- Download URL: rustex-0.2.1-cp37-none-win_amd64.whl
- Upload date:
- Size: 298.4 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0096d8f886688c7cd36ed06b1982fa95077e2ecbe7aa9159d36888ae34738052
|
|
| MD5 |
2c35f74537135a109b4df08a4cbce1b9
|
|
| BLAKE2b-256 |
624f1649e9134b2e1d6d5dec3315c2ca66387a54712da781ddb44d701fb2fd2a
|
File details
Details for the file rustex-0.2.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.
File metadata
- Download URL: rustex-0.2.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf0def62dee838c8da8da64625ff5cd2253ab48f5300fde5dc38c3dced4706f8
|
|
| MD5 |
cd13e47e12f34688b1448c28328e73e8
|
|
| BLAKE2b-256 |
f132b120d664e6149752035d78335c6db29a310c0698b5bbc25dc195b7444558
|
File details
Details for the file rustex-0.2.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.
File metadata
- Download URL: rustex-0.2.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 868.3 kB
- Tags: CPython 3.7m, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6da822f94d6354a3650259b3f1dd55f08d2e06f963d56a343b2985df7eeac44
|
|
| MD5 |
51c47345350a5b7758ea9094db24a417
|
|
| BLAKE2b-256 |
b1d1f96120af95626d4fdcf47dac9ef43d2fa052cc287e6133b812909c7dc2cc
|