Comments (4)
This is not a remnant, but a way to cleanly fail instead of having the finalizer randomly break (ex: on interpreter shutdown). __finalizer_dict
exists both to enforce the finalization order between instances (basically: the USB context object must be kept alive for any object obtained from it can be finalized) and to allow the "owner" instance to cascade closure requests to its dependents (closing a device handle closes all transfers related to that device).
So if two finalizers fall into the same entry in __finalizer_dict
, it is a bug, and this raise is here to alert about this before this becomes the usual nightmare of garbage-collection-related heisenbugs, which themselves could turn into segfaults when libusb calls happen in the wrong order.
Could you post more of the traceback which leads to this failure ? Especially, I wonder which class' __registerFinalizer
this is about, and what the caller is so I can figure out what the handle is computed from and hence guess why it may be reused.
Also, do you have a suggestion to clarify the intent of those raises, so they do not look like they may be leftover debugging code ?
EDIT: finalization order happens because references to the required objects are held by the finalizer itself, not by __finalizer_dict
.
from python-libusb1.
Especially, I wonder which class'
__registerFinalizer
this is about, and what the caller is so I can figure out what the handle is computed from and hence guess why it may be reused.
That was USBDeviceHandle
. Probably I got some other exception and it's crashed in the finalizer instead of whichever other way it was going to...
from python-libusb1.
Is there a way for me to try to replicate this issue ? I unfortunately have very little time these days (which I would otherwise spend trying to get the new python-libusb1 version out, master has several improvements which were long overdue) but maybe I can figure something out.
At least, I did a quick try of the python-functionfs
usbcat example (running device.py
with CPython3 and host.py
with pypy3 7.3.14), using kernel's dummy_hcd
, sent a few packets back and forth and did not get any obvious failure.
In case you would like to reproduce, it goes like this:
Terminal 1, in python-functionfs
:
$ sudo modprobe dummy_hcd
$ sudo modprobe libcomposite
$ virtualenv vpy3
$ vpy3/bin/pip install .
$ sudo vpy3/bin/python examples/usbcat/device.py
Terminal 2, in python-libusb1
:
$ virtualenv -p pypy3 vpypy3
$ vpypy3/bin/pip install .
$ sudo vpypy3/bin/python .../examples/usbcat/host.py
But this may be too simple of an example to have a chance of triggering the issue.
from python-libusb1.
Is there a way for me to try to replicate this issue ?
Unfortunately the way I discovered it is by running an userspace RGMII PHY driver with Glasgow on PyPy3.9.
from python-libusb1.
Related Issues (20)
- Add PyInstaller Hook HOT 7
- threading.Condition.notifyAll has been deprecated in favour of notify_all in Python 3.10 HOT 1
- Getting OSError: exception: access violation writing HOT 58
- Getting OSError in dlopen with the libusb-1.0.dylib installed by homebrew for Apple M1
- libusb_set_option support HOT 23
- Device Leak Issue under Windows HOT 10
- OSError: dlopen failed: library "libusb-1.0.so" not found HOT 4
- build fails against setuptools 58+ HOT 8
- 2.0.1 fails to build with Python 3.11.0a2 HOT 5
- question: comparison with pyusb HOT 2
- Do the bulk transfer APIs handle fragmentation? HOT 3
- Segmentation fault on every function call HOT 3
- libusb stress_mt.c conversion to python-libusb1 HOT 9
- Event handler context HOT 3
- Needs a binding for libusb_interrupt_event_handler HOT 5
- How to set `libusb_transfer.flags` HOT 2
- Feature request: USBContext.handleEventsCompleted() HOT 3
- Fix Release Signatures on PyPI (404 Not Found) HOT 5
- Errors on Windows HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-libusb1.