Skip to content

feat: encode PID #24

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: encode PID #24

wants to merge 1 commit into from

Conversation

cocoa-xu
Copy link

Encode PID as Bytes objects

Signed-off-by: Cocoa <i@uwucocoa.moe>
@josevalim
Copy link
Contributor

Thank you! ❤️ @jonatanklosko do we want to convert it to bytes or actually wrap it around a new Python object?

@jonatanklosko
Copy link
Member

Yes, we discussed this offline :) I would create the pythonx python module as part of init here:

pythonx/c_src/pythonx.cpp

Lines 425 to 428 in 6db2d79

sys.stdout = Stdout(0)
sys.stderr = Stdout(1)
sys.stdin = Stdin()
)";

It would be something like this:

import types
import sys

pythonx = types.ModuleType("pythonx")

class PID:
  def __init__(self, bytes):
    self.bytes = bytes

pythonx.PID = PID

sys.modules["pythonx"] = pythonx

Then in the NIF we can call PyImport_AddModule("pythonx"), get the PID attribute and call it with the bytes as argument.

Then in another PR we would add send as another function in that module.

@cocoa-xu if there are any issues with this approach let me know!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants