简体   繁体   中英

A multi-threaded python program with a strange requirement :)

Is the following possible in python using the mechanize module ?

Having 2 threads in a program, both accessing the same web server, but one of them is actually logged into the server with a user/pass, while the other thread is just browsing the same web server without logging in.

I see that if I login to a webserver (say X) using mozilla, and then I open chrome I am not logged in automatically and I have to login again in chrome. I want to have the same behaviour in a python multithreaded program, where one thread is logged in and the other is not. What would be a suitable way to do this ?

Thanks for any tips !

Simply use two different instances of mechanize.Browser . As both use their own chain of handlers, they don't share cookies, logins, etc... It doesn't really matter if you use them from different threads or not, they're completely isolated in any case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM