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.

Minor code clean up

See original GitHub issue
  • Change from
    return await self._client.mget(keys[0], *keys[1:])
    
    to the
    return await self._client.mget(*keys)
    

  • Change from
    if isinstance(value, int) or value.isdigit():
       return int(value)
    
    to the
    if isinstance(value, int)
        return value
    if value.isdigit():
        return int(value)
    

  • Refactor magic hidden converting under the hood from microseconds to seconds based only on variable type:
           if isinstance(expire, float):
               pexpire = int(expire * 1000)
               expire = None
  • This seems to be unnecessary because on __del__ call self._client will be deleted too:

      def close(self):
         del self._client
         self._client = None
         self.__is_init = False
    
     __del__ = close
    

  • Using class none: pass seems to be redundant because None is pickled and unpickled back. I do not understand the purpose of the
          value = pickle.loads(value, fix_imports=False, encoding="bytes")
    
          if value is none:
              return None
    
    because you can remove at all class none: pass class, and just do return value.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Krukovcommented, Feb 8, 2022

Yep, thank to point it. I hope that is no doubts about socket_keepalive - the same setting we have in our browsers in it set to true. To be honest there is no reason why socket_timeout is exactly 0.1 by default. I just want to set it with a small amount based on my experience. We had an issues with cache when it stacked and we got the whole app down by the end just because timeout had a big value or didn’t set. I don’t think that we can count the value for socket timeout, but for cache it should be extremely small just because of the purpose of cache.

I saw some redis benchmarks and they said that average response time is 200 us ( 0.0002 sec) ! and 100 percentile took less then 3 ms ( 0.003 sec) (https://redis.io/topics/benchmarks) !

Do you have some suggestions for that value?

1reaction
Krukovcommented, Feb 7, 2022

@AIGeneratedUsername Can I ask you for review this PR ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Minor code cleanup [#2841268] | Drupal.org
This removes the LICENSE.txt file, cleans up the module's structure a bit, and adds media_wysiwyg as a dependency. Log in or register to...
Read more >
Code Cleanup: 7 Simple Daily Steps That Pay off in the End
Code cleanup doesn't have to be an arduous job. Learn seven simple steps you can perform daily to keep your codebase in great...
Read more >
Minor code cleanup by dbaeumer · Pull Request #132 · microsoft/lsif ...
Minor code cleanup #132 ... Hiding of all comments behaves strange when one PR is checked out and one not microsoft/vscode-pull-request-github#2936.
Read more >
Bringing Code Cleanup on Save To Visual Studio 2022 17.1 ...
First, navigate to Analyze > Code Cleanup > Configure Code Cleanup to personalize desirable customizations to your code cleanup profile(s).
Read more >
Code style and cleanup | JetBrains Rider Documentation
Violations of code formatting rules as well as some other minor inconsistencies are not highlighted for the reason of keeping your code readable ......
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