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

Error using VS-Code and reloading v1.1.2 #22

Closed
PFython opened this issue Mar 5, 2024 · 2 comments
Closed

Error using VS-Code and reloading v1.1.2 #22

PFython opened this issue Mar 5, 2024 · 2 comments

Comments

@PFython
Copy link

PFython commented Mar 5, 2024

I just read about reloading on Medium, installed the latest version with pip, but failed to get even the simple starting example to run using VS-Code as my IDE:

>>> from reloading import reloading
>>> for i in reloading(range(10)):
...     # this code will be reloaded before each iteration
...     print(i)
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\peter\AppData\Roaming\Python\Python311\site-packages\reloading\reloading.py", line 45, in reloading
    return _reloading_loop(fn_or_seq, every=every)       
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^       
  File "C:\Users\peter\AppData\Roaming\Python\Python311\site-packages\reloading\reloading.py", line 168, in _reloading_loop
    compiled_body, itervars, loop_id = get_loop_code(loop_frame_info, loop_id=loop_id)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\peter\AppData\Roaming\Python\Python311\site-packages\reloading\reloading.py", line 138, in get_loop_code
    tree = parse_file_until_successful(fpath)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\peter\AppData\Roaming\Python\Python311\site-packages\reloading\reloading.py", line 88, in parse_file_until_successful
    source = load_file(path)
             ^^^^^^^^^^^^^^^
  File "C:\Users\peter\AppData\Roaming\Python\Python311\site-packages\reloading\reloading.py", line 82, in load_file
    with open(path, "r") as f:
         ^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument: '<stdin>'
@julvo
Copy link
Owner

julvo commented Mar 6, 2024

Thanks for reporting this. It looks like vscode is piping the python source via stdin into the python interpreter. The current implementation of reloading can't see which file the source code came from when tracking source code changes.

To use reloading, please run the file directly, e.g. python my_module.py

@julvo julvo closed this as completed Mar 6, 2024
@PFython
Copy link
Author

PFython commented Mar 6, 2024

Thanks for the explanation Julian! Is this a possible future feature request, or just too difficult?

It might be worth mentioning in the documentation at least?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants