Hi i have 2 python files and first file for data and its working with timer, example first file timer is set for 02/05/2023 - 02:50am
and when this date is come this file triggered and opens the order, but 2st file is checks this order status i mean 2st file is only for checks status and if this order succes its print 'SUCCES'
and if its not its print 'FAIL'
but it need to open like 2-3 days but its fail and says:
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))
i dont want to solve binance problem bec its nearly impossible, i found solution for this i write this command in terminal every time:
while true; do python3 /home/pi/Desktop/EREN/2-SHORTnormal/Loop.py && break; done
'This command help me for if its crash for anything like timestamp, time out or anything its start again '
but every time :(
- Im waiting the trigger date (example 02/05/2023-02:50am) and i dont want to wake up for
- open termnial write this command bla bla
- WHAT I WANT:
- I only want these files in one file like when i start the program its wait for trigger date and when its trigger i want it to start other file and if its crash i want to restart this program automatically but not to entire command, only the second one because if its start entire code its wait for trigger again but its cant trigger bec the trigger date it will already be past. How i can do this in python
example if this is my code:
Print('order is sent') #this is first files command and this work good
#and then
while status == succes
Print('order status:',status) #this is second files command
But second part crashes sometimes and i want to re open when it crashes until its status == success
but only second part not whole code.
CodePudding user response:
Okey i think i found the solution:
import time #my 1.Command out the while loop, while True: try: #my 2.Command continue except: print("Program has crashed and restarts in 2 sec.") time.sleep(2) continue
if 2.Command is crash its print something and restart program. And 1.Command is run for only 1 time this is what i. want