python multiprocessing.Process

在使用Kafka-python时自己写的一个bug

我在一个进程的__init__中初始化了一个producer,但是一直不好用

但是在函数里直接new一个就好用了

why?

需要说明的是producer中新建了一个sender,这个sender是一个线程

这是一个相似的问题,作者给出了解答

https://github.com/dpkp/kafka-python/issues/570

 

为何在__init__中初始化一个实例成员和run()中初始化会不一样

init的时候进程还没创建,只是新建了这么个类

参考的博客:

http://blog.csdn.net/qdx411324962/article/details/46810421

https://my.oschina.net/leejun2005/blog/203148

https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Process.start

 

posted @ 2017-09-08 17:01  Earendil  阅读(222)  评论(0编辑  收藏  举报