Results 1 to 10 of 10

Thread: Python wait command

  1. Administrator Bunni's Avatar
    Join Date
    08-29-07
    Posts
    14,279
    Post Thanks / Like
    Blog Entries
    7
    Stat Links

    Python wait command Python wait command Python wait command Python wait command Python wait command
    Gamer IDs

    Steam ID: bunni Bunni's Originid: Dr_Bunni
    #1

    Python wait command

    I have two functions, simplistically function A writes a file, function B formats the written file.

    However it seems that function A takes a few seconds to write the file, so when B is executed, it cannot find the file to format because it has not yet been written and so error city yada yada...

    Ive been surfing pythons api but have yet to find an adequate wait function or something to delay function B from being executed before the file is written.

    Does anyone have any ideas?

    Any and all help will be greatly appreciated!
    Bun-

  2. Registered TeamPlayer QuickLightning's Avatar
    Join Date
    08-03-07
    Posts
    11,943
    Post Thanks / Like
    #2

    Re: Python wait command

    Well, if there is no NOP command in python, why not just create a FOR loop that just incriminates an irrelevant variable a few thousand times? It's inefficient but it would work.


  3. Administrator Bunni's Avatar
    Join Date
    08-29-07
    Posts
    14,279
    Post Thanks / Like
    Blog Entries
    7
    Stat Links

    Python wait command Python wait command Python wait command Python wait command Python wait command
    Gamer IDs

    Steam ID: bunni Bunni's Originid: Dr_Bunni
    #3

    Re: Python wait command

    Quote Originally Posted by QuickLightning
    Well, if there is no NOP command in python, why not just create a FOR loop that just incriminates an irrelevant variable a few thousand times? It's inefficient but it would work.
    the only problem then is that it might work on one server, but then on another (more powerful) server may take quite less time to (seconds to miliseconds).
    Need something that works in all scenarios :3

  4. Registered TeamPlayer
    Join Date
    07-14-07
    Posts
    4,667
    Post Thanks / Like
    #4

    Re: Python wait command

    duct tape. :9

  5. Registered TeamPlayer QuickLightning's Avatar
    Join Date
    08-03-07
    Posts
    11,943
    Post Thanks / Like
    #5

    Re: Python wait command

    Quote Originally Posted by Bunni
    Quote Originally Posted by QuickLightning
    Well, if there is no NOP command in python, why not just create a FOR loop that just incriminates an irrelevant variable a few thousand times? It's inefficient but it would work.
    the only problem then is that it might work on one server, but then on another (more powerful) server may take quite less time to (seconds to miliseconds).
    Need something that works in all scenarios :3
    If time is not an issue (that is, you are not holding up other processes that are time critical by doing so) why not just find a suitable wait time using the above idea, and multiply it by 10 or so... I'd love to be of more help but python is not my strong suit as far as programming languages are concerned. I'm having my own issues with tcl right now.


  6. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Python wait command
    #6

    Re: Python wait command

    What mechanism are you using such that function A and function B are running independently? Threads? Different scripts? Depending on how your doing it, a different solution is necessary.

    And yes just spinning on a variable waiting for an event should be avoided.

    FYI to delay in python
    Code:
    import time
    
    timeInMilliseconds = 1000
    time.sleep(timeInMilliseconds)

  7. Administrator Bunni's Avatar
    Join Date
    08-29-07
    Posts
    14,279
    Post Thanks / Like
    Blog Entries
    7
    Stat Links

    Python wait command Python wait command Python wait command Python wait command Python wait command
    Gamer IDs

    Steam ID: bunni Bunni's Originid: Dr_Bunni
    #7

    Re: Python wait command

    Quote Originally Posted by Ewok
    What mechanism are you using such that function A and function B are running independently? Threads? Different scripts? Depending on how your doing it, a different solution is necessary.

    And yes just spinning on a variable waiting for an event should be avoided.

    FYI to delay in python
    Code:
    import time
    
    timeInMilliseconds = 1000
    time.sleep(timeInMilliseconds)
    crashes the server, hard. Q_Q

  8. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Python wait command
    #8

    Re: Python wait command

    While python is running, nothing else in the game engine can run, hence the hang since the python code is not returning because of the wait.

    I'm still confused over this function B, where does it live and what's running it?



  9. Administrator Bunni's Avatar
    Join Date
    08-29-07
    Posts
    14,279
    Post Thanks / Like
    Blog Entries
    7
    Stat Links

    Python wait command Python wait command Python wait command Python wait command Python wait command
    Gamer IDs

    Steam ID: bunni Bunni's Originid: Dr_Bunni
    #9

    Re: Python wait command

    Hmm for stats printing out at a specified time, whats better: using the python event scheduler (sched), or threading.Timer?

  10. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Python wait command
    #10

    Re: Python wait command

    using a sdk built in timer

    Code:
    class SomeClass(object):
      def __init__(self):
        sdk.createTimer(seconds, self.myCallback)
    
      def myCallback(self, privateData, timer):
        # Do stuff
    We want to avoid using python threads as much as possible (the python scheduler also uses python threads). What you want to do can easily be done using the sdk timer.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
Title