Skip to content

Commit

Permalink
Updated for changes in latest modal-client
Browse files Browse the repository at this point in the history
  • Loading branch information
ConProgramming committed Apr 15, 2023
1 parent 52bf2c7 commit ec38e13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/vite/sveltekit_modal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async def unicorn_exception_handler(request: Request, exc: Exception):
)


@stub.asgi(**config.get('stub_asgi'))
@stub.function(**config.get('stub_asgi'))
@stub.asgi_app()
def app():
return web_app
23 changes: 5 additions & 18 deletions src/vite/sveltekit_modal/serve.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import sys
import traceback

from synchronicity import Interface
from modal.cli.app import _show_stub_ref_failure_help
from modal_utils.async_utils import synchronizer
from modal_utils.package_utils import NoSuchStub, import_stub, parse_stub_ref
from modal.cli.import_refs import import_stub
from modal._live_reload import run_serve_loop

from .sveltekit_modal_config import config

Expand All @@ -19,12 +17,13 @@
'.venv',
'site-packages',
'.idea',
#'node_modules',
# 'node_modules',
'.mypy_cache',
'.pytest_cache',
'.hypothesis',
)


class Logger(object):
def __init__(self, stream):
self.stream = stream
Expand All @@ -45,16 +44,4 @@ def flush(self):


if __name__ == '__main__':
parsed_stub_ref = parse_stub_ref('sveltekit_modal.app')
try:
stub = import_stub(parsed_stub_ref)
except NoSuchStub:
_show_stub_ref_failure_help(parsed_stub_ref)
sys.exit(1)
except Exception:
traceback.print_exc()
sys.exit(1)

_stub = synchronizer._translate_in(stub)
blocking_stub = synchronizer._translate_out(_stub, Interface.BLOCKING)
blocking_stub.serve(stdout=Logger(sys.stdout), show_progress=True)
run_serve_loop('sveltekit_modal.app', stdout=Logger(sys.stdout), show_progress=True)

0 comments on commit ec38e13

Please sign in to comment.