Python论坛  - 讨论区

标题:[python-chinese] 多进程连接数据库

2007年07月25日 星期三 10:47

leopay leopay在gmail.com
星期三 七月 25 10:47:34 HKT 2007

dbconn={
    'user':             'root',
    'passwd':           '123456',
    'db':               'test',
}

def main():
    conn=MySQLdb.connect(**dbconn)
    cursor=conn.cursor()
    for i in xrange(2):
        pid=os.fork()
        cursor.execute('select * from test')
        print cursor.fetchall()



Ϊʲô»á³öÏÖ£ºMySQL server has gone away
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070725/03833271/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年07月25日 星期三 15:01

lau stephen liusifan在gmail.com
星期三 七月 25 15:01:32 HKT 2007

fork µÄʱºò£¬conn ÄÚ²¿Ê¹ÓõÄÁ¬½Óµ½ mysql server µÄ socket fd ÔÚ client Õâ±ß±» duplicate ÁË£¬µ«ÊÇÔÚ
mysql server ÄDZ߻¹ÊÇÖ»ÓÐÒ»¸ö¡£
È»ºóÕâ¶Î³ÌÐòÔËÐйý³ÌÖУ¬Óнø³ÌÏÈÍ˳öÁË£¬Õâ¸öÏÈÍ˳öµÄ½ø³ÌÔÚÍ˳öʱ°Ñ socket fd ¹Ø±ÕÁË£¬¶ø mysql server Ò²ÊÕµ½ÁËÕâ¸ö¹Ø±ÕµÄ tcp
·Ö½Ú£¬È»ºó mysql server ¾Í°ÑÕâ¸ö socket ¹Ø±ÕÁË¡£µ«Êǵ±Ê±ÕýÔÚÔËÐеÄÆäËû½ø³Ì¾Í»á±¨´íÁË¡£

Òò´Ë£¬Ò»°ãÀ´Ëµ£¬ÔÚ fork ֮ǰÊDz»½¨Òé´ò¿ª client socket µÄ¡£ÔÚ fork Ö®ºóÔÙ´ò¿ª¡£

ÔÚ07-7-25£¬leopay <leopay在gmail.com> дµÀ£º
>
> dbconn={
>     'user':             'root',
>     'passwd':           '123456',
>     'db':               'test',
> }
>
> def main():
>     conn=MySQLdb.connect(**dbconn)
>     cursor=conn.cursor()
>     for i in xrange(2):
>         pid=os.fork()
>         cursor.execute('select * from test')
>         print cursor.fetchall ()
>
>
>
> Ϊʲô»á³öÏÖ£ºMySQL server has gone away
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070725/72636ca8/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年07月25日 星期三 23:48

leopay leopay在gmail.com
星期三 七月 25 23:48:41 HKT 2007

ллÁË

ÔÚ07-7-25£¬lau stephen <liusifan在gmail.com> дµÀ£º
>
> fork µÄʱºò£¬conn ÄÚ²¿Ê¹ÓõÄÁ¬½Óµ½ mysql server µÄ socket fd ÔÚ client Õâ±ß±» duplicate
> ÁË£¬µ«ÊÇÔÚ mysql server ÄDZ߻¹ÊÇÖ»ÓÐÒ»¸ö¡£
> È»ºóÕâ¶Î³ÌÐòÔËÐйý³ÌÖУ¬Óнø³ÌÏÈÍ˳öÁË£¬Õâ¸öÏÈÍ˳öµÄ½ø³ÌÔÚÍ˳öʱ°Ñ socket fd ¹Ø±ÕÁË£¬¶ø mysql server Ò²ÊÕµ½ÁËÕâ¸ö¹Ø±ÕµÄ
> tcp ·Ö½Ú£¬È»ºó mysql server ¾Í°ÑÕâ¸ö socket ¹Ø±ÕÁË¡£µ«Êǵ±Ê±ÕýÔÚÔËÐеÄÆäËû½ø³Ì¾Í»á±¨´íÁË¡£
>
> Òò´Ë£¬Ò»°ãÀ´Ëµ£¬ÔÚ fork ֮ǰÊDz»½¨Òé´ò¿ª client socket µÄ¡£ÔÚ fork Ö®ºóÔÙ´ò¿ª¡£
>
> ÔÚ07-7-25£¬leopay <leopay在gmail.com> дµÀ£º
> >
> >  dbconn={
> >     'user':             'root',
> >     'passwd':           '123456',
> >     'db':               'test',
> > }
> >
> > def main():
> >     conn=MySQLdb.connect(**dbconn)
> >     cursor=conn.cursor()
> >     for i in xrange(2):
> >         pid=os.fork()
> >         cursor.execute('select * from test')
> >         print cursor.fetchall ()
> >
> >
> >
> > Ϊʲô»á³öÏÖ£ºMySQL server has gone away
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070725/839dd52e/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号