小编yig*_*yig的帖子

Python多处理与uuid.uuid4()不能很好地协同工作

我正在尝试为文件名生成一个uuid,我也在使用多处理模块.令人不快的是,我所有的uuids都完全一样.这是一个小例子:

import multiprocessing
import uuid

def get_uuid( a ):
    ## Doesn't help to cycle through a bunch.
    #for i in xrange(10): uuid.uuid4()

    ## Doesn't help to reload the module.
    #reload( uuid )

    ## Doesn't help to load it at the last minute.
    ## (I simultaneously comment out the module-level import).
    #import uuid

    ## uuid1() does work, but it differs only in the first 8 characters and includes identifying information about the computer.
    #return uuid.uuid1()

    return uuid.uuid4()

def main():
    pool = …
Run Code Online (Sandbox Code Playgroud)

python random time uuid multiprocessing

6
推荐指数
1
解决办法
1591
查看次数

标签 统计

multiprocessing ×1

python ×1

random ×1

time ×1

uuid ×1