crossbario / crossbario/autobahn-python

NVX: netmap loop

Open
#966 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs-discussion wamp websocket
Dominant language
Python
Stars
2.5k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

While migrating the Ueberschall accelerator code here, I stumbled over some sketch code that is worth keeping back to some day.

c = 0
stats = {}


def start(app):
    # set inbox/outbox to first configured RX/TX queue (eg from a NIC or an NVMe)
    app.inbox.append(app.rx[0].queue)
    app.outbox.append(app.tx[0].queue)

    # start looping with freq capped to 100 Hz (or 10 ms period)
    app.loop(100)

def loop(app):
    # process incoming message (mbuf) queued in inbox
    for msg in app.inbox:

        # msg is a mbuf instance
        n = len(msg)

        # stopping the app with error
        if n > 1000:
            app.stop(Exception(u'msg too long! stopping'.encode()))

        # loop can keep state from outer scope
        if n not in stats:
            stats[n] = 0
        stats[n] += 1

        # mbuf handling
        msg2 = msg.duplicate()
        msg2.write(20, b'hello')

        # queue outgoing message (mbuf) in outbox
        app.outbox.send(msg2)

        # stopping the app with success, returning a result
        if c > 10000:
            result = {u'total': c, u'stat': stats}
            app.stop(result)

def stop(app):
    # stop or restart the app
    if app.err:
        print('unexpected error - exciting', app.err)
    else:
        # restart the app
        app.start()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by searching the repository for NVX, netmap, Ueberschall, and the app.inbox/app.outbox loop concepts shown in the issue. The issue contains only exploratory Python sketch code; work is not well-defined until the project identifies an entry point, intended behavior, and acceptance criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.