A module that allows you to make changes to a running python script and reload it
Project description
PyReload
Library for quick interaction with the code in the file. PyReload - allows you to update the code in real time
Configuration
In order not to keep track of all the files, they can be placed in the ignore file, according to the standard it is '._ingore'. To do this, you will need:
1. Create a ignore file
2. Add ignored files
3. Run the script (if the file is called differently, then pass its name through the 'ignore_file' parameter)
ps: Creating a file is optional
# Example ignore file
pr = PyReload(ignore_file = 'custom_name_ignore_file.txt')
Examples
pyreload + aiogram
# update code in framework aiogram
import os
from pyreload import PyReload
...
async def pyreload_task():
while 1:
await pr.update_file.hash().async_run()
await asyncio.sleep(1)
async def on_startup(_):
logging.info("Bot started")
logging.info("Started waiting reload")
asyncio.create_task(pyreload_task())
if __name__ == '__main__':
pr = PyReload(path=os.listdir())
executor.start_polling(dp, skip_updates=True, on_startup=on_startup)
pyreload + vkbottle
# update code in framework aiogram
import os
from pyreload import PyReload
...
@bot.loop_wrapper.interval(seconds=1)
async def pyreload_task():
await pr.update_file.hash().async_run()
if __name__ == '__main__':
pr = PyReload(path = os.listdir())
bot.run_forever()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-reload-0.1-0.tar.gz
(3.0 kB
view details)
File details
Details for the file python-reload-0.1-0.tar.gz
.
File metadata
- Download URL: python-reload-0.1-0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4fb281143a497093184c521e6883115800444fac6b4144531bef7f71460b72a |
|
MD5 | 6b3769eda9dafc3c1a062afe4647416d |
|
BLAKE2b-256 | 9f72c65961b6f6b29cd9621c7461a0a4a82e16d17f70d355dee37d0e95f83898 |