#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0

    Duplicate logs while spawning two threads


    Hi,

    While spawning two different threads using Thread from threading module i am getting duplicate logs in log file.

    Creating two threads in this way :
    t = Thread(target = check_Input_Status_Action.thresholdCheck, args = (thresholdTime,))
    t.start()

    t1 = Thread(target = check_Input_Status_Action.main, args = (sys.argv,))
    t1.start()

    But if call the above two statements with small sleep in between them then the duplicate log problem doesn't coming.

    Could you please help me in knowing that when we spawn two threads in the consecutive statements does this problem occur or do we need to give some time lag in while calling these two statements.


    Thanks
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Temporal delay usually isn't the best answer. Investigate mutual exclusion.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo