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

when running paper-trade mode, DELETE requests lead to unhandled exception (err 500) #394

Closed
movy opened this issue Feb 18, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@movy
Copy link
Contributor

movy commented Feb 18, 2023

Saleh,
I hope this finds you well.

On the latest Jesse on Ubuntu 22.04 w/ python 3.8, whenever I try to stop Jesse in paper trading session (as opposite to live trading) I cannot terminate live trading session via UI as server throws the following:

INFO:     172.94.47.97:58608 - "DELETE /live HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/uvicorn/protocols/http/h11_impl.py", line 369, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/usr/local/lib/python3.8/dist-packages/uvicorn/middleware/proxy_headers.py", line 59, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/fastapi/applications.py", line 259, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/cors.py", line 92, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/cors.py", line 147, in simple_response
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 82, in __call__
    raise exc
  File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.8/dist-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.8/dist-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 259, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 61, in app
    response = await func(request)
  File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 226, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 161, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/local/lib/python3.8/dist-packages/starlette/concurrency.py", line 39, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/usr/local/lib/python3.8/dist-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.8/dist-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.8/dist-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/jesse/__init__.py", line 440, in cancel_backtest
    process_manager.cancel_process(f'{trading_mode}-' + request_json.id)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/jesse/services/multiprocessing.py", line 84, in cancel_process
    pid = self.get_pid(client_id)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/jesse/services/multiprocessing.py", line 81, in get_pid
    return self.client_id_to_pid_to_map[self._prefixed_client_id(client_id)]
KeyError: '9001|livetrade-1'

I added extra logging, and turns out the key is supposed to be 9001|papertrade-1:

{'9001|papertrade-1': '9001|32263'}
@movy movy added the bug Something isn't working label Feb 18, 2023
@movy movy changed the title when running live mode on port other than 9000 DELETE requests lead to unhandled exception (err 500) when running paper-trade mode, DELETE requests lead to unhandled exception (err 500) Feb 21, 2023
@movy
Copy link
Contributor Author

movy commented Feb 21, 2023

This is actually a frontend issue, see jesse-ai/dashboard#1

@movy movy closed this as completed Feb 21, 2023
@saleh-mir
Copy link
Member

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

No branches or pull requests

2 participants