summaryrefslogtreecommitdiff
path: root/omegle.py
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-05-28 15:36:07 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-05-28 15:36:07 +0000
commitd636287ebd99cf4ad044624970869eb97ffafe47 (patch)
treef934700d75a8b535f97fa4d8846fc5031cc9b7c6 /omegle.py
parentf3a07bcf2fc2bcaae96a6b6f7b8d07c804515cf4 (diff)
downloadomegle-d636287ebd99cf4ad044624970869eb97ffafe47.tar.gz
omegle-d636287ebd99cf4ad044624970869eb97ffafe47.zip
buuuh
git-svn-id: http://xapek.org/svn/common/omegle@1029 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
Diffstat (limited to 'omegle.py')
-rw-r--r--omegle.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/omegle.py b/omegle.py
index d80075a..9a75a26 100644
--- a/omegle.py
+++ b/omegle.py
@@ -4,7 +4,7 @@ import urllib
import time
import json
import logging
-from threading import Thread, Lock, Condition
+from threading import Thread, Lock, Event
__all__ = ['OmegleChat', 'get_count']
@@ -22,19 +22,20 @@ class Timer(Thread):
self.running = False
- self.lock = Condition()
+ self.event = Event()
def run(self):
self.running = True
- self.lock.acquire()
while self.running:
+ self.logger.debug("Timer.run itertaion")
self.func()
- self.lock.wait(self.interval)
+ self.event.wait(self.interval)
+ self.event.clear()
self.logger.debug("self.running == False")
def stop(self):
self.running = False
- self.lock.notify()
+ self.event.set()
class RESTClient(object):
headers = {
@@ -57,7 +58,7 @@ class RESTClient(object):
class OmegleChat(RESTClient):
- def __init__(self,poll_interval=0.5):
+ def __init__(self,poll_interval=0.5,name=""):
RESTClient.__init__(self,'www.omegle.com')
self.timer = Timer(self.events, poll_interval)
@@ -188,7 +189,9 @@ if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
print "Lets chat. Type \"quit\" to disconnect"
chat = OmegleChat()
- chat.on_disconnect = lambda: sys.exit(0)
+ def exit(self):
+ sys.exit(0)
+ chat.on_disconnect = exit
chat.start()
while 1==1:
try: