PyExt module

C extension interface.

PyExt.FFI

cffi interface.

Type

ffi

PyExt.FFILIB

cffi library.

Type

object

class PyExt.EvPoll[source]

Bases: object

Evpoll interface.

ffi

cffi interface.

Type

ffi

ffilib

cffi library.

Type

object

pollpairs

cffi polling pair buffer.

Type

object

close()[source]

Handle close.

modify(evfd, events)[source]

Modify event flag.

Parameters
  • evfd (int) – File descriptor.

  • events (int) – Event flag.

Returns

None

poll(timeout, maxevts=65536)[source]

Poll events.

Parameters
  • timeout (int) – Timeout.

  • maxevts (int) – Maximum number of events which are polled.

Returns

Event pairs (fd, events).

Return type

[(int, int)]

register(evfd, events)[source]

Register event.

Parameters
  • evfd (int) – File descriptor.

  • events (int) – Event flag.

Returns

None

unregister(evfd)[source]

Unregister event.

Parameters

evfd (int) – File descriptor.

Returns

None

PyExt.create_task(exe_path, argv, envp, fd_mapping, work_path, root_path, uid, gid, timelimit, memlimit, restrict_level)[source]

Create a task.

Parameters
  • exe_path (string) – Executable file path.

  • argv ([string]) – List of arguments.

  • envp ([string]) – List of environment variables.

  • fd_mapping (dict) – File descriptor mapping.

  • work_path (string) – Working directory.

  • root_path (string) – Root directory.

  • uid (int) – UID of sandbox.

  • gid (int) – GID of sandbox.

  • timelimit (int) – Timelimit of sandbox.

  • memlimit (int) – Memlimit of sandbox.

  • restrict_level (int) – Restriction level of sandbox.

Returns

Task ID, or None if failed to create the task.

Return type

int

PyExt.emit_task()[source]

Emit tasks.

PyExt.init()[source]

Initialize the module.

PyExt.start_task(task_id, callback, started_callback=None)[source]

Start a task.

The task may be pended if the running queue is full.

Parameters
  • task_id (int) – Task ID.

  • callback (function) – Done callback.

  • started_callback (function, optinal) – Started callback.

Returns

None