简体   繁体   English

python - pyro连接数

[英]python - number of pyro connections

I'm using python and writing something that connects to a remote object using Pyro4 When running some unit tests (using pyunit) that repeatedly connects to a remote object with pyro, I found I couldn't run more than 9 tests or the tests would get stuck and just hang there. 我正在使用python并使用Pyro4编写连接到远程对象的东西当运行一些使用pyro重复连接到远程对象的单元测试(使用pyunit)时,我发现我无法运行超过9个测试或测试会陷入困境,只是挂在那里。

I've now managed to fix this by using with Pyro4.Proxy(PYRONAME:name) as pyroObject: do something with object... 我现在设法通过使用Pyro4.Proxy(PYRONAME:name)作为pyroObject来解决这个问题:用对象做一些事情......

whereas before I was creating the object in the test set up: def setUp(self): self.pyroObject = Pyro4.Proxy(PYRONAME:name) 而在我在测试设置中创建对象之前:def setUp(self):self.pyroObject = Pyro4.Proxy(PYRONAME:name)

and then using self.pyroObject within the tests 然后在测试中使用self.pyroObject

Does anyone know why this has fixed the issue? 有谁知道为什么这解决了这个问题? Thanks 谢谢

When you're not cleaning up the proxy objects they keep a connection live to the pyro daemon. 当你没有清理代理对象时,他们会保持与pyro守护进程的连接。 By default the daemon accepts 16 concurrent connections. 默认情况下,守护程序接受16个并发连接。

If you use the with.. as... syntax, you're closing the proxy cleanly after you've done using it and this releases a connection in the daemon, making it available for a new proxy. 如果你使用with ... as ...语法,那么你在使用它之后就会干净地关闭代理,这会在守护进程中释放一个连接,使其可用于新的代理。

You can increase the number of 16 by increasing Pyro's threadpool size via the config. 您可以通过配置增加Pyro的线程池大小来增加16的数量。 Alternatively you could perhaps use the multiplex server type instead of the default threaded one. 或者,您也许可以使用Multiplex服务器类型而不是默认的线程服务器类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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