ragflow icon indicating copy to clipboard operation
ragflow copied to clipboard

Singleton func bugs?

Open idiotTest opened this issue 1 year ago • 1 comments

Is there an existing issue for the same bug?

  • [X] I have checked the existing issues.

Branch name

main

Commit ID

abc_singleton

Other environment information

No response

Actual behavior

the singleton fuc is :


def singleton(cls, *args, **kw):
    instances = {}

    def _singleton():
        key = str(cls) + str(os.getpid())
        if key not in instances:
            instances[key] = cls(*args, **kw)
        return instances[key]

    return _singleton

Expected behavior

I think it'is :

def singleton(cls):
    instances = {}

    def _singleton(*args, **kw):
        key = str(cls) + str(os.getpid())
        if key not in instances:
            instances[key] = cls(*args, **kw)
        return instances[key]

    return _singleton

Steps to reproduce

...

Additional information

No response

idiotTest avatar Apr 20 '24 13:04 idiotTest

Sorry, I don't get it. Why don't you submit a pull request?

KevinHuSh avatar Apr 21 '24 02:04 KevinHuSh