Thread: Event Loops

    #1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11

    Event Loops


    Hi

    I was wondering how would I make an event loop and how would I design it...

    Thanks
    Those people who think they know everything are a great annoyance to those of us who do.
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Don't be so vague. Tell us more than an event loop. Right now I have no clue what you want.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    I want to know an example of a event loop for maybe a server like the select module but it is a pyd file so I can't look at it, but like what are the purposes of one and how do u construct them...

    Basicly everything I can know
    Those people who think they know everything are a great annoyance to those of us who do.
  6. #4
  7. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Code:
    while 1:
        print '.'
    ?
    I still don't understand what you mean by an event loop. A loop is exactly what I just showed you. Do you want it to run as a separate thread?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    well A event loop as I get it from the cookbook is a loop which waits for multiple things:

    Like when you have a loop and it waits for a connection and a client tries to connect and then once it has the connection it returns to the event loop and goes on for example listening or connections again

    but it does mutlipe things at the same time...
    Those people who think they know everything are a great annoyance to those of us who do.
  10. #6
  11. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    You need a while loop and the threading module. What you can do is create a function in which your loop will run under. And use the threading module's Timer() function to call the function that contains the while loop. This will run your loop forever, allowing other tasks to be in progress as well.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    ya but there are multiple processes running it the event loop

    Like listening for connections, sending messages, and recving messages: and it goes on one of these when it gets it and continues the loop after the message was sent for example
    Those people who think they know everything are a great annoyance to those of us who do.
  14. #8
  15. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    I don't see why there is a need for this. Simply use the threading module's Timer() function and run multiple, separate loops through the functions that are used by the Timer() functions that you set up.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    Okay well the whole point for me is to understand how to construct a event loop
    Those people who think they know everything are a great annoyance to those of us who do.
  18. #10
  19. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Is there a specific reason why you need to do so? There are other options (such as the one I told you already).
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    not there is not real need it is okay thanks
    Those people who think they know everything are a great annoyance to those of us who do.

IMN logo majestic logo threadwatch logo seochat tools logo