Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create durable nested function #117

Open
pelletier opened this issue Mar 8, 2024 · 0 comments
Open

Cannot create durable nested function #117

pelletier opened this issue Mar 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@pelletier
Copy link
Contributor

pelletier commented Mar 8, 2024

Reproduction:

import httpx
from fastapi import FastAPI

from dispatch.fastapi import Dispatch

app = FastAPI()

dispatch = Dispatch(app)

def main():
    @dispatch.function
    async def sub1():
        return 42

    @dispatch.function
    async def main():
        await sub1()

    @app.get("/")
    def root():
        main.dispatch()
        return "OK"

main()

This results in the following error:


[DURABLE] Serializing DurableCoroutine(main.<locals>.main):
function = main.<locals>.main (/Users/thomas/src/github.com/stealthrocket/dispatch-py/bug_reproduction.py:16)
code hash = sha256:8188f279bc2ec3e905fc0e115713b13c1e5b8f571f046f081cf8ac4aed9585a8
args = ()
kwargs = {}
wrapped coroutine = None
frame state = -1
IP = 28
SP = 2
stack[0] = <cell at 0x10536dc60: Function object at 0x1053794e0>
stack[1] = DurableCoroutineWrapper(Function._call_async)

unexpected exception occurred during coroutine scheduling
Traceback (most recent call last):
  File "/Users/thomas/.venv/dispatch-tester/lib/python3.12/site-packages/dispatch/scheduler.py", line 215, in run
    return self._run(input)
           ^^^^^^^^^^^^^^^^
  File "/Users/thomas/.venv/dispatch-tester/lib/python3.12/site-packages/dispatch/scheduler.py", line 424, in _run
    serialized_state = pickle.dumps(state)
                       ^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle 'cell' object
INFO:     2600:1f13:6ac:6005::3b0:0 - "POST /dispatch.sdk.v1.FunctionService/Run HTTP/1.1" 200 OK

Python build:

Python 3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
@pelletier pelletier added the bug Something isn't working label Mar 8, 2024
@chriso chriso self-assigned this Mar 10, 2024
@chriso chriso removed their assignment Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants