Skip to content

Conversation

@agners
Copy link
Contributor

@agners agners commented Aug 13, 2025

This is an internal function used during cleanup, and we can't really do anything about it. Even when correctly using the Python library (e.g. acquiring the semaphore with timeout=0), in some rare cases the something to avoid this call.

Fixes: #52

This is an internal function used during cleanup, and we can't really
do anything about it. Even when correctly using the Python library (e.g.
acquiring the semaphore with timeout=0), in some rare cases the
something to avoid this call.
@cbornet
Copy link
Owner

cbornet commented Aug 21, 2025

Thanks for the report and PR.
How about putting the exclusion on ThreadPoolExecutor.submit (and ProcessPoolExecutor.submit ?) instead as it's the usual way to call blocking code in the event loop and it has a smaller scope than _acquire_restore ?

@agners
Copy link
Contributor Author

agners commented Aug 21, 2025

How about putting the exclusion on ThreadPoolExecutor.submit (and ProcessPoolExecutor.submit ?) instead as it's the usual way to call blocking code in the event loop and it has a smaller scope than _acquire_restore ?

Hm, I was thinking that _acquire_restore() is smaller scope as it is further down the call chain. But I guess it depends where _acquire_restore() gets called. Since the actual blocking call is in there, wouldn't it be better to have that function specifically excluded?

In any case, my reproducer is not able to reproduce the issue with the exclusions you suggest, so it does work too in practice.

@agners
Copy link
Contributor Author

agners commented Aug 21, 2025

I've updated the PR to target ThreadPoolExecutor.submit. I think the ProcessPoolExecutor doesn't need the same treatment.

@cbornet cbornet changed the title Add _acquire_restore to ignored methods Add ThreadPoolExecutor.submit to ignored methods Aug 30, 2025
@cbornet cbornet merged commit 33bb625 into cbornet:main Aug 30, 2025
@cbornet
Copy link
Owner

cbornet commented Aug 30, 2025

Thanks for a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blockbuster sometimes detect blocking call when using acquire(timeout=0) on threading.Semaphore

2 participants