Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved]Help with Threading
#3
If I do this t = threading.Timer(5,waiting(command)) to try and pass the command to my waiting() it ignores the 5sec timer:
    #-------------------------------------------------------------------------------------
    #                               Set Reminders
    #-------------------------------------------------------------------------------------
    if ('remind me' in command):
        command = command.replace("remind me", "")    
        autoTypeAnimation("Ok, I will remind you" + command)
        import threading
        t = threading.Timer(5,waiting(command))
        t.start()

def waiting(command):
    print("Reminder Set")
    # Wait 5s then bring up reminder
    # time.sleep(5)
    autoTypeAnimation("FYI: I was told to remind you" + command)
& it will throw this error:
Error:
Commander: Exception in thread Thread-1: Traceback (most recent call last): File "C:\Users\BX-PC\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner self.run() File "C:\Users\BX-PC\AppData\Local\Programs\Python\Python39\lib\threading.py", line 1286, in run self.function(*self.args, **self.kwargs) TypeError: 'NoneType' object is not callable
But if I do (don't pass the command to the waiting()):
    #-------------------------------------------------------------------------------------
    #                               Set Reminders
    #-------------------------------------------------------------------------------------
    if ('remind me' in command):
        command = command.replace("remind me", "")    
        autoTypeAnimation("Ok, I will remind you" + command)
        import threading
        t = threading.Timer(5,waiting)
        t.start()

def waiting():
    print("Reminder Set")
    # Wait 5s then bring up reminder
    # time.sleep(5)
    autoTypeAnimation("FYI: I was told to remind you")
It works as intended.

Is there any way to have it so I can pass the command value to the waiting function & have it work properly?
Reply


Messages In This Thread
[Solved]Help with Threading - by Extra - Sep-04-2022, 06:51 PM
RE: Help with Threading - by Gribouillis - Sep-04-2022, 07:40 PM
RE: Help with Threading - by Extra - Sep-04-2022, 08:12 PM
RE: Help with Threading - by Gribouillis - Sep-04-2022, 09:00 PM
RE: Help with Threading - by Extra - Sep-04-2022, 09:09 PM
RE: Help with Threading - by Extra - Sep-04-2022, 10:24 PM
RE: Help with Threading - by deanhystad - Sep-05-2022, 02:12 AM
RE: Help with Threading - by Extra - Sep-05-2022, 05:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Concurrent futures threading running at same speed as non-threading billykid999 13 2,284 May-03-2023, 08:22 AM
Last Post: billykid999
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,260 Oct-01-2021, 08:32 PM
Last Post: muzikman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020