Pausing python programs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Graham

    Pausing python programs

    How can I cause a python program to pause/suspend execution for a period of
    time? I am checking status of an external system and only want to check
    every second as opposed to my current which checks may times a secnod and
    hogs my cpu in the process!!!

    Thank you to anyone who can help.

    Graham Smith

    PeopleSoft Technical Team Leader
    OXFAM GB
    +44 (1865) 313255
    gsmith@oxfam.or g.uk



  • max khesin

    #2
    Re: Pausing python programs

    Graham wrote:
    [color=blue]
    > How can I cause a python program to pause/suspend execution for a period of
    > time? I am checking status of an external system and only want to check
    > every second as opposed to my current which checks may times a secnod and
    > hogs my cpu in the process!!!
    >
    > Thank you to anyone who can help.
    >
    > Graham Smith
    >
    > PeopleSoft Technical Team Leader
    > OXFAM GB
    > +44 (1865) 313255
    > gsmith@oxfam.or g.uk
    >
    >
    >[/color]
    Sleep() (at least on windoze) will suspend your app from execution. From
    some experiments I think Python's time.sleep() uses it.
    max

    Comment

    • Graham

      #3
      Re: Pausing python programs

      Thanks Max. Big help.
      regards


      Comment

      • Martin Franklin

        #4
        Re: Pausing python programs

        On Thu, 2004-01-29 at 09:41, Graham wrote:[color=blue]
        > How can I cause a python program to pause/suspend execution for a period of
        > time? I am checking status of an external system and only want to check
        > every second as opposed to my current which checks may times a secnod and
        > hogs my cpu in the process!!!
        >
        > Thank you to anyone who can help.
        >
        > Graham Smith
        >
        > PeopleSoft Technical Team Leader
        > OXFAM GB
        > +44 (1865) 313255[/color]
        gsmith@oxfam.or g.uk


        You should really get into pydoc:-) For example

        pydoc time

        Help on module time:

        NAME
        time - This module provides various functions to manipulate time
        values.

        FILE
        /usr/local/lib/python2.3/lib-dynload/time.so


        <snip>


        Functions:

        time() -- return current time in seconds since the Epoch as a float
        clock() -- return CPU time since process start as a float
        sleep() -- delay for a number of seconds given as a float
        gmtime() -- convert seconds since Epoch to UTC tuple
        localtime() -- convert seconds since Epoch to local time tuple
        asctime() -- convert time tuple to string
        ctime() -- convert time in seconds to string
        mktime() -- convert local time tuple to seconds since Epoch
        strftime() -- convert time tuple to string according to format
        specification strptime() -- parse string to time tuple according to
        format specification
        tzset() -- change the local timezone



        so time.sleep(1) could be what you are after.

        Also don't forget google is you friend :-)

        Cheers
        Martin


        --
        Martin Franklin <mfranklin1@gat wick.westerngec o.slb.com>


        Comment

        Working...