comatose
comatose

Reputation: 1962

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 !

Upvotes: 0

Views: 77

Answers (1)

mata
mata

Reputation: 69062

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.

Upvotes: 1

Related Questions