Changeset 221:c5912b9d2cf9 for imapclient/examples/idle_example.py
- Timestamp:
- 17/04/11 11:33:16 (13 months ago)
- Branch:
- default
- Files:
-
- 1 modified
-
imapclient/examples/idle_example.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
imapclient/examples/idle_example.py
r208 r221 1 # This example is a lot more interesting if you have an active client 2 # connected to the same IMAP account! 3 1 4 from imapclient import IMAPClient 2 import time3 5 4 6 HOST = 'imap.host.com' … … 8 10 9 11 server = IMAPClient(HOST, use_uid=True, ssl=ssl) 12 server.login(USERNAME, PASSWORD) 13 server.select_folder('INBOX') 10 14 11 server.login(USERNAME, PASSWORD) 15 # Start IDLE mode 16 server.idle() 12 17 13 select_info = server.select_folder('INBOX') 14 print select_info 15 print 18 # Wait for up to 30 seconds for an IDLE response 19 responses = server.idle_check(timeout=30) 20 print responses 16 21 17 idling = True 18 19 def callback(resp, arg): 20 global idling 21 22 print "Something happened, or timeout was reached" 23 print 24 print "Callback response:" 25 print resp 26 print 27 print "The callback function received arg: ", arg 28 print 29 idling = False 30 31 server.idle(timeout=5, callback=callback, cb_arg="Hello future self!") 32 print "Began idling" 33 34 while idling: 35 print "..still idling.." 36 time.sleep(1) 22 # Come out of IDLE mode 23 text, responses = server.idle_done() 24 print 'IDLE done. Server said %r' % text 25 print 'Final responses: ', responses 37 26 38 27 print server.logout()
