Skip to content

Commit

Permalink
double precision for seconds (#33)
Browse files Browse the repository at this point in the history
* double precision for seconds
* fix asyncio example
  • Loading branch information
mosquito authored Nov 16, 2020
1 parent 16d1a76 commit d9c9a8e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cysystemd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package_info = "SystemD wrapper in Cython"
version_info = (1, 4, 4)
version_info = (1, 4, 5)


author_info = (("Dmitry Orlov", "[email protected]"),)
Expand Down
8 changes: 5 additions & 3 deletions cysystemd/reader.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ cdef class JournalEntry:
def cursor(self):
return self.cursor

def get_realtime_sec(self):
return self.realtime_usec / 1000000.
cpdef double get_realtime_sec(self):
cdef double result = self.realtime_usec / 1000000.
return result

def get_monotonic_sec(self):
cpdef double get_monotonic_sec(self):
cdef double result = self.monotonic_usec / 1000000.
return self.monotonic_usec / 1000000.

cpdef uint64_t get_realtime_usec(self):
Expand Down
5 changes: 5 additions & 0 deletions examples/asyncio_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ async def main():
await reader.seek_head()
# await reader.previous(10)

# read all from cursor immediately
async for record in reader:
print(json.dumps(record.data, indent=1, sort_keys=True))

# waiting for new events and print them
while await reader.wait():
async for record in reader:
print(json.dumps(record.data, indent=1, sort_keys=True))
Expand Down

0 comments on commit d9c9a8e

Please sign in to comment.