| 63 | |
| 64 | |
| 65 | class PythonEnv: |
| 66 | def __init__( |
| 67 | self, |
| 68 | python_bin: str = "python3", |
| 69 | prologue: Optional[str] = None, |
| 70 | shell: str = "bash", |
| 71 | ): |
| 72 | """ |
| 73 | Describes an environment for spawning Python interpreters. |
| 74 | :param python_bin: Python binary that will be executed. |
| 75 | :param prologue: Shell command that will be executed prior to launching the Python interpreter. |
| 76 | :param shell: Shell used for executing `prologue`. |
| 77 | """ |
| 78 | code = "from hyperqueue.task.function import task_main as m; m()" |
| 79 | |
| 80 | if prologue: |
| 81 | self.args = [shell, "-c", f'{prologue}\n\n{python_bin} -c "{code}"'] |
| 82 | else: |
| 83 | self.args = [python_bin, "-c", code] |
| 84 | |
| 85 | |
| 86 | class PythonFunction(Task): |
no outgoing calls