question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Buffer class makes unexpected RPC calls

See original GitHub issue

The Buffer class makes unexpected RPC calls.

This is due to the __len__ method being called during boolean tests.

For example, the following code will print 2.

class Example:
    def __len__(self) -> int:
        print(2)
        return 0


example = Example()

if example:
    pass

This is very surprising behaviour, and there is absoutely no way to fix it without breaking backwards compatibility.

But it should be documentated, because this will actually break your code if you are using Buffer class from another thread.

It took me a quite a bit of effort to figure out that an or statement was causing crashes in my plugin.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
blueyedcommented, Jul 13, 2020

It could also implement __bool__ itself (returning True always), couldn’t it? https://docs.python.org/3.8/reference/datamodel.html?highlight=__del__#object.__bool__

0reactions
justinmkcommented, Aug 30, 2020

PR welcome. We monkey-patch various things, this is more or less idiomatic in python land.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Question - Photon RPC Buffer Execution Delay - Unity Forum
I've noticed that if a move is made and one client isn't responding - the RPC call doesn't get received. So far I...
Read more >
Remote Procedure Calls
When B returns, the return value is passed to A and A continues execution. This mechanism is called the Remote Procedure Call (RPC)....
Read more >
Veeam Agent backup job fails with "Failed to call RPC function ...
A Veeam Agent backup job managed by the backup server fails with the following error:Processing Error: Failed to call RPC function ...
Read more >
Overview | Protocol Buffers - Google Developers
Compact data storage; Fast parsing; Availability in many programming languages; Optimized functionality through automatically-generated classes ...
Read more >
Error Handling in gRPC - Baeldung
gRPC is a platform to do inter-process Remote Procedure Calls (RPC). ... Java encapsulates this error model with the class io.grpc.Status.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found