1. You could modify massimo's commet_messaging.py to use
https://github.com/kmike/tornadio. It also uses tornado but is based
on socket.io and gives you the choice of the following transports:
WebSocket
Adobe® Flash® Socket
AJAX long polling
AJAX multipart streaming
Forever Iframe
JSONP Polling
2.
> > Coz the office of my clients are Restricted to port  80 and port 443 only , 
> > no choice left)
websockets are over 80 and 443 the only problem is proxy servers mess
them up. That mainly applies to plain websockets
wss or secure websockets work in 90% of setups  because it is
encrypted and the proxy can not see the contents of the packet. If you
fall in the 10% the you can choose one of the other options on the
preceding list but they all have performance weaknesses compared to
websockets.



> > Currently my approach for my Comet-Like Ajax Progressbar is to do like this
> > :
>
> > -Process huge list of file . Every 1000th file , write Progress number to a
> > file (that is run outside of web2py , called via subprocess module) .
> > -Web2py ajax controller check_progress() reads that file WHEN Requested from
> > it's index.html. Like every 3 second (not long polling , and cause a lot of
> > IO hits . not really good)
>
> > I am wanting to implement a Long Polling comet directly inside Web2py's
> > Rocket web server and i need pointers, as i am also busy with my project. I
> > will contribute back ofcoz.

if you insist on this method rather than massimos messaging.py
then you can use
http://packages.python.org/watchdog/quickstart.html#a-simple-example
to find out when the file changes. I would use a while loop with a
sleep command in it.
set the condition of the while to a var set in handlers closure
something like:

def index():
    import time
    from watchdog.observers import Observer
    from watchdog.events import FileSystemEventHandler
    progressupdate=False
    class YourHandler(FileSystemEventHandler):
        def on_modified(self, event):
            #do your stuff
            progressupdate=True

    observer = Observer()
    observer.schedule(YourHandler, path='.', recursive=True)
    observer.start()
    while not progressupdate:
        time.sleep(1)
    observer.stop()
    observer.join()
    return dict(progressupdate=progressupdate)

you will need to check any intermediate servers and make sure they do
not have a timeout.
You really should impliment some sort of timeout yourself.

Reply via email to