Skip to content

Key does not correctly work on class instance methods #27

@togakangaroo

Description

@togakangaroo

Consider this:

In [81]: 
class Foo:

  @AsyncTTL(time_to_live=10)
  async def getval(self): return random.random()

In [82]: await (fooA := Foo()).getval(), await fooA.getval(), await Foo().getval()
Out[83]: (0.9306262352193505, 0.9306262352193505, 0.9306262352193505)

The expectation is that you would get the same value for the first two but a different one for the third as the actual instance is different and therefore hash(self) is different.

The issue seems to be in the implementation of KEY which doesn't use hash at all if you're a class for some reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions