Results 1 to 6 of 6

Thread: thread,time and sleep in Python

  1. #1
    Join Date
    May 2008
    Posts
    222

    thread,time and sleep in Python

    hi everyone

    I am creating a simple program in Python and I need some help and suggestion.The program contains two statement in a function and i want my display the execution of first statement and then after the seconds should be displayed.If you all have any idea !!!!!! will be helpful for me.

    Thanks.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Thread,time and sleep in Python

    If you are developing your web application or any program within Python and you need to some help and suggestion then I would be very glad.

    According to query,you need some statement to display after point of time.The available library functions can help you much more.You need to use those resources to achieve your concept.

    The Number of library functions are available to help you for executing what you want.This is some of the function like Time.sleep,sleep,time for advance management of the events.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Time.sleep function in Python

    Time.sleep function

    The Time.sleep function is used to sleep the connected statement in the program for a given time.According to the nature of function time.sleep(), It restricts the execution of program according to parameter for the time period.

    The example for this event -

    Code:
     while True:
    
          checkSomething()
    
     Print 'Welcome...'               
     time.sleep(2)
     print 'Welcome...after two second'

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Threads in Python

    Threads in Python:

    If you need to execute so many processes which requires to execute at asingle point of time means overall ,you want to perform several things at the same time,then threads can help in this case.

    It allows you to construct the list of processes which you need to execute.You can set up a number of processes or sub-processes and each of which can be run independently but which can be brought back together later and/or co-ordinated as they run.

    The thread concept is used for large and heavy loaded application.

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Constructing thread in Python

    Constructing thread in Python

    The thread can be constructed in the Python program.Just construct a program which requires a network connection and need to find the availability of computers in the network.

    The code which will show you the position of the 10 computers in the network :

    Code:
    import os
    import re
    import time
    import sys
    
    lifeline = re.compile(r"(\d) received")
    report = ("No response","Partial Response","Alive")
    
    print time.ctime()
    
    for hst in rng(60,70):
       ip = "192.168.200."+str(hst)
       pingaling = os.popen("ping -q -c2 "+ip,"r")
       print "Testing ",ip,
       sys.stdout.flush()
       while 1:
          line = pingaling.readline()
          if not line: break
          igot = re.findall(lifeline,line)
          if igot:
               print report[int(igot[0])]
    
    print time.ctime()

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Sleep function in Python

    Sleep function in Python:

    The sleep function is used with different Import behaviors but here i will show you the code which is constructed with time.The code will follow the sequence as follows -

    Code:
    .
    .
    .
     
    img3 = "Helinks.GIF"
    photo3 = PhotoImage(file=img3)
     
    time.sleep(10)
     
    img4 = "Tom.GIF"
    photo4 = PhotoImage(file=img4)
     
    .
    .
    .

Similar Threads

  1. vista monitor sleep after some time
    By Q Jones in forum Windows Vista Performance
    Replies: 1
    Last Post: 07-06-2011, 12:59 AM
  2. Synchronize a producer thread and a consumer thread in C#
    By Ayuka in forum Software Development
    Replies: 6
    Last Post: 10-11-2010, 04:04 AM
  3. Time Warner Cable DVR Sleep Mode
    By Don't Matter in forum Monitor & Video Cards
    Replies: 3
    Last Post: 04-08-2009, 12:01 PM
  4. How to Interrupt Sleep Function in Python
    By Xena in forum Software Development
    Replies: 3
    Last Post: 13-04-2009, 03:08 PM
  5. Download Python 3.0 / Python 3000
    By Amaresh in forum Software Development
    Replies: 6
    Last Post: 24-02-2009, 09:28 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,921,438.87228 seconds with 17 queries