Comments (5)
I'm not sure this is something we'd want to add tenacity specific handling for.
I imagine the common usage pattern would be to define a serializer that works for your expected / successful return value (since that's what you want to cache). The fact that your serializer needs to handle all possible unhandled exceptions, even though you have no intent to cache them, is very surprising behavior. What if some other situation arises where an exception is raised that isn't json serializable?
I agree that tenacity specific handling probably isn't warranted, but I wonder if it's possible to implement more generic handling that allows retries to be executed, and task state to be correctly assigned (failed) even when the exception isn't serializable?
Does using an alternate serializer solve this issue for you?
I've implemented some other handling here - now that I know of this particular issue, I can catch this specific exception and replace it with something that's serializable by default. But I also think it's something Prefect should probably be able to handle by default.
from prefect.
Thanks for raising this one @thundercat1 and for providing workarounds in case others come across it. I've added this issue to our backlog.
from prefect.
hi @thundercat1 - I think this issue has mostly to do with the fact that you cannot pickle a _thread.RLock
object in general
import pickle
import threading
def minimal_repro():
lock = threading.RLock()
try:
pickle.dumps(lock)
except TypeError as e:
print(f"Pickling error: {e}")
if __name__ == "__main__":
minimal_repro() # Pickling error: cannot pickle '_thread.RLock' object
if you use result_serializer="json"
, your example works (i.e. fails as expected). I'm not sure this is something we'd want to add tenacity specific handling for. Does using an alternate serializer solve this issue for you?
from prefect.
The core problem here appears to be that we are persisting (and therefore serializing) exceptions; in general I don't like this and don't think it's necessary - I'll look at whether any functionality depends on that and whether we can safely remove it. That being said, I want to callout that if a user uses a distributed system (like Dask or Ray), then the same error would occur because those systems would need to serialize the exception to send it across the network. I think we can look at opening an issue in tenacity to avoid maintaining a lock reference on raised exceptions.
from prefect.
Ha, looks like someone has raised this issue with tenacity already: jd/tenacity#429
from prefect.
Related Issues (20)
- `3.0.0rc14` or `3.0.0rc15` starts prefect server on every app start HOT 5
- Make Flow Version Available in the Runtime HOT 1
- Fix flaky test `tests/test_task_engine.py::TestTaskRunsAsync::test_get_run_logger[False]`
- Generic Secure Block HOT 4
- Task hangs due to multiprocessing.Pool.join() HOT 1
- PREFECT_API_URL not recognized even though it is set HOT 5
- Serializable isolation level for transactions
- Error on KubernetesJob.publish_as_work_pool()
- Cannot pass dict as a parameter 'data' to Completed state on Prefect v3.0.0rc16 HOT 4
- flow.to_deployment().serve() does not work HOT 4
- Deployment Concurrency Limits HOT 2
- Add json serializer for tasks that return a pydantic model
- flow run execute with wrong order when lower priority queue contain many flow runs HOT 2
- Add volume configuration in worker.json HOT 3
- K8s worker fails monitoring flow and sets it to crashed.
- Local server randomly not working HOT 5
- Create/Update command for work pool
- Publish OpenAPI YAML spec in CI/CD HOT 1
- Make schedules interface more expressive
- Redeploying a flow activates inactive schedules
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 prefect.