help using sockets, and OOP?
exarkun at divmod.com
Sun Dec 5 23:29:26 CET 2004
On Mon, 06 Dec 2004 07:45:34 +1000, Dfenestr8 <chrisdewinn0spam at yahoo.com.au> wrote:
>On Sun, 05 Dec 2004 20:17:31 +0000, Jp Calderone wrote:
> > Your problem doesn't seem to have anything to do with "OOP" (whatever
> > that is). Rather, you are trying to use two blocking sockets at once.
> > socket.connect() and socket.recv() are both "blocking" operations by
> > default - they can take an arbitrary amount of time to return.
> > Additionally, Botling.receiveData, one of your own functions, is also
> > blocking: it will actually loop forever, never returning (until an
> > exception blows it up). So execution of your program never even
> > _gets_ to the "bert2 = ..." line. It's stuck running
> > bert1.receiveData().
> Ok, so what if I remove the while loop from the Botling class, and include
> it in the __main__ ? Might this work as a solution then?
> if __name__ == '__main__':
> bert1 = Botling("^berty^", "#exciting", "irc.interesting.org")
> bert2=Botling("^berty^", "#interesing", "irc.exciting.org")
> while 1:
Try adding a simple print statement here, so you can see how often the program begins executing this while loop.
And here so you can see when bert1.receiveData() has finished.
And here so you can see when bert2.receiveData() has finished.
More information about the Python-list