ERPNext Biometric Integration Windows Service Error

Hi, manually when erpnext_sync.py is run in cmd line it works.

When installed as a windows service and try to start the service. The below msg displays,

windows-service-msg

Below is the error details which i got in event log,

Python could not import the service’s module
Traceback (most recent call last):
File “C:\TimeAttendance\biometric-attendance-sync-tool-master\erpnext_sync_win.py”, line 4, in
from erpnext_sync import main
File “C:\TimeAttendance\biometric-attendance-sync-tool-master\erpnext_sync.py”, line 305, in
status = pickledb.load(‘/’.join([config.LOGS_DIRECTORY, ‘status.json’]), True)
File “C:\Program Files\Python36\lib\site-packages\pickledb.py”, line 43, in load
return PickleDB(location, auto_dump, sig)
File “C:\Program Files\Python36\lib\site-packages\pickledb.py”, line 57, in init
self.set_sigterm_handler()
File “C:\Program Files\Python36\lib\site-packages\pickledb.py”, line 77, in set_sigterm_handler
signal.signal(signal.SIGTERM, sigterm_handler)
File “C:\Program Files\Python36\lib\signal.py”, line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
%2: %3

I have the same problem! Did you resolve it? Thank you

Did you resolve it? Can’t find any solution!

Faced the same error with the windows service. So found an alternative to use Windows Task Scheduler to schedule frequent run for the script. Also for this to work make sure that the local_config.py file has been correctly configured. You can invoke the erpnext_sync.py program manually once to do the initial sync and double check if everything is working fine.

You can add a new task in Windows Task Scheduler with the following settings. This will run the script every 5 mins and sync the updated data with your erpnext system.

  1. New Task

  2. Add Trigger to run every day at interval of 5 minutes

  3. Start action
    a) Provide path to where python is installed. I have version 3.10, your directory will change based on which version you have installed.
    b) Option Parameter - provide the name of the script erpnext_sync.py (not the erpnext_sync_win.py). This script will be executed.
    c) Start Directory - Where you have stored the erpnext_sync.py file. Make sure no one moves or deletes the directory. Also ensure that the path as a trailing ** in the end.

  4. In the conditions change so that only 1 instance is running at a given time. The initial sync can take longer.

1 Like