PyWebIO icon indicating copy to clipboard operation
PyWebIO copied to clipboard

already in script mode

Open itsshreyarora opened this issue 3 years ago • 4 comments

I am running my code but it shows already in script mode and fails to start server

image

itsshreyarora avatar Apr 15 '21 14:04 itsshreyarora

It seems like that you use path_deploy() to start pywebio server. Do you call any input or output functions of pywebio before path_deploy() call? In Server mode, PyWebIO’s input and output functions can only be called in the context of task functions.

See also: https://pywebio.readthedocs.io/en/latest/guide.html#server-mode-and-script-mode

wang0618 avatar Apr 15 '21 15:04 wang0618

@wang0618 working on Google colab notebook faced same issue : IMG_20220127_025845

Another one : IMG_20220127_030432


SessionNotFoundException Traceback (most recent call last) in () 9 10 if name=='main': ---> 11 app()

5 frames in app() 5 from pywebio.session import local 6 def app(): ----> 7 put_text("hello PyWebIO") 8 9

/usr/local/lib/python3.7/dist-packages/pywebio/output.py in put_text(sep, inline, scope, position, *texts) 377 """ 378 content = sep.join(str(i) for i in texts) --> 379 spec = _get_output_spec('text', content=content, inline=inline, scope=scope, position=position) 380 return Output(spec) 381

/usr/local/lib/python3.7/dist-packages/pywebio/output.py in _get_output_spec(type, scope, position, **other_spec) 352 353 if not scope: --> 354 scope_name = get_scope() 355 else: 356 scope_name = scope

/usr/local/lib/python3.7/dist-packages/pywebio/output.py in get_scope(stack_idx) 292 """ 293 try: --> 294 return get_current_session().get_scope_name(stack_idx) 295 except IndexError: 296 logger.exception("Scope stack index error")

/usr/local/lib/python3.7/dist-packages/pywebio/session/init.py in get_current_session() 235 236 def get_current_session() -> "Session": --> 237 return get_session_implement().get_current_session() 238 239

/usr/local/lib/python3.7/dist-packages/pywebio/session/threadbased.py in get_current_session(cls) 303 def get_current_session(cls) -> "ScriptModeSession": 304 if cls.instance is None: --> 305 raise SessionNotFoundException("Can't find current session. It might be a bug.") 306 if cls.instance.closed(): 307 raise SessionClosedException()

SessionNotFoundException: Can't find current session. It might be a bug.

SessionNotFoundException: Can't find current session. It might be a bug.

algopy avatar Jan 26 '22 21:01 algopy

@algopy PyWebIO don't support running in Google colab notebook

wang0618 avatar Jan 28 '22 10:01 wang0618

@wang0618 Can it be possible by using ngrok or local tunnel in colab? How to deploy pywebio app from heroku or azure cloud?

algopy avatar Jan 28 '22 21:01 algopy