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.

…offset does not match… exception when files exist that are meaningless to current platform

See original GitHub issue

Currently, the code in unix.py for get_localzone() assumes that if any of several platform-specific files exists, then it is actually relevant and appropriate to use. That turns out to be a pretty unsafe assumption though.

It is very common, for instance, for a /etc/sysconfig/clock file to exist on a CentOS 7 system because someone assumed that what used to work on CentOS 6 (based on Sys-V) still applies to CentOS 7 (which is based on systemd) as well. If the system’s timezone is actually still UTC because that didn’t work, or if the system’s timezone is later changed to one that no longer matches what the junk /etc/sysconfig/clock file says, then calling get_localzone() causes ValueError: Timezone offset does not match system offset: <value 1> != <value 2>. Please, check your config files.

I would be willing to work on a pull request to improve that.

My suggestion is to check whether the system is based on systemd and to then only check either the files that are relevant for systemd or those relevant to other init systems (Sys-V, etc.) If it is not possible to determine whether the system is based on systemd, then check all files as we do now.

is_systemd = None
try:
    init_ps = next(
        (ps for ps in psutil.process_iter(['pid', 'name']) if ps.pid >= 1),
        None)
    if init_ps:
        is_systemd = init_ps.name == 'systemd'
except Exception:
    pass

This kind of implementation would require adding a dependency on the psutil package. Another option would be to run the ps command in a subprocess.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
regebrocommented, Oct 18, 2021

And 4.0 is released, so I’m closing this.

1reaction
regebrocommented, Oct 8, 2021

Beta’s with this refactoring is out now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python pytz timezone function returns a timezone that is off by ...
"A pytz timezone class does not represent a single offset from UTC, it represents a geographical area which, over the course of history,...
Read more >
List of the armlink error and warning messages - Arm Developer
The ARM Compiler Errors and Warnings Reference Guide provides lists of the errors and warnings that each of the compilation tools can generate....
Read more >
XCOFF Object File Format - IBM
Specifies a file pointer (byte offset from the beginning of the file) to the start of the symbol table. If the value of...
Read more >
API Reference — fsspec 2022.11.0+13.g0974514.dirty ...
Creates directory at path and any intervening required directories. Raises exception if, for instance, the path already exists but is a file. Parameters....
Read more >
2 Server Error Message Reference - MySQL :: Developer Zone
Occurs for failure to create or copy a file needed for some operation. Possible causes: Permissions problem for source file; destination file already...
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