Comments (3)
That's not how asyncio works, we can't cancel if you don't yield back to the event loop anywhere (e.g. with an await
).
Use await asyncio.sleep(1)
, not time.sleep()
, which is a blocking function resulting in your application not being able to handle any other async tasks.
from async-timeout.
Ah how do I abort an execution from an external library without support to async calls? I'm using the package
rdkit and the function rdkit.Chem.rdDetermineBonds.DetermineBondOrders sometimes takes forever to execute, and I want to add a timeout funcionality. I was hoping async-timeout would save me, but when I write this code:
async with timeout(1):
await rdDetermineBonds.DetermineBondOrders(conn_mol, charge=mol_charge)
To force rdDetermineBonds.DetermineBondOrders
abort after 1 second, raising an error (that I will catch as Exception in my code). But it didn't work! Am I having a wrong understanding about how async works? My problem can be solved using this library?
EDIT: I'm not willing to deal with rdkit source code, so I wish an external solution.
from async-timeout.
It should work, so I'd file a bug against rdkit if it doesn't. The reasons that the timeout doesn't work are likely that rdkit isn't yielding to the event loop (which they should be if it's meant to be an async interface), or they are catching and suppressing the CancelledError.
from async-timeout.
Related Issues (20)
- Missing typing_extensions package HOT 1
- It would be nice if timeout could be used as decorator HOT 1
- Please tag a new stable release HOT 4
- `asyncio.TimeoutError` raised on network timeout and CPU timeout HOT 1
- Discussion: should black and other packages be moved from requirements.txt HOT 1
- Dependabot couldn't authenticate with https://pypi.python.org/simple/
- concurrent.futures._base.CancelledError for when timeout happend.
- 3.0.1: test suite warnings HOT 3
- shift_by replaces delay HOT 1
- aiohttp swallows asyncio.CancelledError during connection timeout HOT 33
- a bug or ? HOT 1
- Compatibility issues with pipenv and python 3.9 HOT 5
- Add `msg` to `task.cancel()` method to allow distinguish the source of cancellation HOT 1
- Tasks are not uncancelled in python 3.11
- Python 3.5.3 requirement HOT 5
- Update all `secret: ` values in `.travis.yml`
- Cancelling current task HOT 6
- nesting HOT 4
- Usage without context (as wait_for) 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 async-timeout.