SKY-ALIN / regta

📅 Production-ready scheduler with async, multithreading and multiprocessing support for Python
https://regta.alinsky.tech
MIT License
21 stars 1 forks source link

PermissionError: [WinError 5] #91

Open mfandre opened 1 month ago

mfandre commented 1 month ago

Im receiving

cd jobs regta run 2024-09-11 10:44:50,848 [regta] [INFO] - [1] jobs were found. Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Scripts\regta.exe__main.py", line 7, in
File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\click\core.py", line 1157, in
call
return self.main(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback,
ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\click\core.py", line 783, in invoke
return
callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\regta\console.py", line 92, in run
run_jobs(classes=classes, logger=logger, use_ansi=use_ansi) File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\regta\utils.py", line 118, in run_jobs
scheduler.run(block=True) File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\regta\schedulers.py", line 168, in run
self.sync_scheduler.run(block=(self.async_scheduler is None and block)) File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\regta\schedulers.py", line 105, in run
self.start_jobs(self._process_jobs, block) File "C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\backend.venv\Lib\site-packages\regta\schedulers.py", line 101, in start_jobs job.start() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64qbz5n2kfra8p0\Lib\multiprocessing\process.py", line 121, in start self._popen = self._Popen(self) ^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64qbz5n2kfra8p0\Lib\multiprocessing\context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64qbz5n2kfra8p0\Lib\multiprocessing\context.py", line 336, in _Popen return Popen(process_obj) ^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64qbz5n2kfra8p0\Lib\multiprocessing\popen_spawn_win32.py", line 95, in init reduction.dump(process_obj, to_child) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64qbz5n2kfra8p0\Lib\multiprocessing\reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) _pickle.PicklingError: Can't pickle <class 'test_jobs.my_period_based_job'>: import of module 'test_jobs' failed PS C:\Users\andre.abc\OneDrive - abc S.A\Documentos_projetos\OmniDocs\jobs> Traceback (most recent call last): File "", line 1, in File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 113, in spawn_main new_handle = reduction.duplicate(pipe_handle, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\reduction.py", line 79, in duplicate return _winapi.DuplicateHandle( ^^^^^^^^^^^^^^^^^^^^^^^^ PermissionError: [WinError 5] Acesso negado

My code

from datetime import timedelta
import regta
from datetime import datetime

@regta.process_job(regta.Period().every(10).seconds)
def my_period_based_job():
    # with open("zica.txt", "a") as f:
    #     f.write(str(datetime.now()))
    return "1. Hello world! This is just a log message."

if __name__== '__main__': 
    pass
SKY-ALIN commented 1 month ago

Hi As I see here regta can't get access to the file with your job and load it. Possibly it's because of OneDrive or OmniDocs, as I see at the log messages, and it's kind of permission conflict in the windows permissions system. Try to open file/folder settings and change permissions and check cloud storage providers settings. Let me know if it helps or it doesn't