Skip to content

Not able to parse the MRT file from pybgpstream #51

@ACodingfreak

Description

@ACodingfreak

Hi All,

When I use the below bgpreader command it just works, but the same with the pybgpstream code shown below is stuck

bgpreader -d singlefile -o upd-file=https://data.ris.ripe.net/rrc00/2023.01/updates.20230120.1420.gz

import pybgpstream

stream = pybgpstream.BGPStream()
stream.set_data_interface("singlefile")
stream.set_data_interface_option("singlefile", "upd-file", "https://data.ris.ripe.net/rrc00/2023.01/updates.20230120.1420.gz")

for rec in stream.records():

    # do something with rec (e.g., choose to continue based on timestamp)
    print("Received %s record at time %d from collector %s" % (rec.type, rec.time, rec.collector))
    count = 0;
    for elem in rec:
        count += 1
        print(type(elem))
        # do something with rec and/or elem

    print ("Total number of elem: %d" % (count))

It gets stuck as shown below

u2004op2:~/bgp/pybgpstream_ex$ python3 01.py 
Received update record at time 1674266321 from collector singlefile
Total number of elem: 0
^CError in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 34, in apport_excepthook
    def apport_excepthook(exc_type, exc_obj, exc_tb):
KeyboardInterrupt

Original exception was:
Traceback (most recent call last):
  File "01.py", line 11, in <module>
    for rec in stream.records():
  File "/home/ipi/.local/lib/python3.8/site-packages/pybgpstream/pybgpstream.py", line 87, in records
    _rec = self.stream.get_next_record()
RuntimeError: Could not get next record (is the stream started?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions