Git Product home page Git Product logo

Comments (5)

thundercat1 avatar thundercat1 commented on August 16, 2024 1

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.

zhen0 avatar zhen0 commented on August 16, 2024

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.

zzstoatzz avatar zzstoatzz commented on August 16, 2024

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.

cicdw avatar cicdw commented on August 16, 2024

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.

cicdw avatar cicdw commented on August 16, 2024

Ha, looks like someone has raised this issue with tenacity already: jd/tenacity#429

from prefect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.