Собственный способ настроить dispy и SSL

Я изо всех сил пытаюсь настроить dispy и SSL. Вот шаги, которые я сделал для настройки:

Для создания сертификата я использовал команду:

openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout private.key -out private.crt -days 3650

Затем я объединил два файла:

cat private.crt private.key > private.pem

В моем конкретном случае мне нужно использовать все: планировщик ( dispyscheduler), узел ( dispynode) и кластер ( SharedJobCluster).

Вот работа, которую я представляю:

# canonical.py
# function 'compute' is distributed and executed with arguments
# supplied with 'cluster.submit' below


def compute(n):
    import time, socket
    time.sleep(n)
    host = socket.gethostname()
    return (host, n)


if __name__ == '__main__':
    # executed on client only; variables created below, including modules imported,
    # are not available in job computations
    import dispy, random
    # distribute 'compute' to nodes; in this case, 'compute' does not have
    # any dependencies to run on nodes
    cluster = dispy.SharedJobCluster(compute,
                                     port=0,
                                  certfile='C:\\project\\private.pem')
    # run 'compute' with 20 random numbers on available CPUs
    jobs = []
    for i in range(5):
        job = cluster.submit(random.randint(5, 5))
        job.id = i # associate an ID to identify jobs (if needed later)
        jobs.append(job)
    # cluster.wait() # waits until all jobs finish
    for job in jobs:
        host, n = job() # waits for job to finish and returns results
        print('%s executed job %s at %s with %s' % (host, job.id, job.start_time, n))
        # other fields of 'job' that may be useful:
        # job.stdout, job.stderr, job.exception, job.ip_addr, job.end_time
    cluster.print_status()  # shows which nodes executed how many jobs etc.

Если я не использую соединение SSL, оно успешно работает, несмотря на использование платформы. Планировщик в Linux и узел в Windows и наоборот. Любая комбинация работает просто отлично. Но проблема возникает, когда я пытаюсь использовать SSL.

Вот команды, которые я использовал для запуска тестового задания:

В линуксе

dispynode.py -d --certfile=/home/dismine/project/private.pem --clean

На винде

python "C:\Program Files\Python3\Lib\site-packages\dispy\dispyscheduler.py" -d --ip_addr 127.0.0.1 --ip_addr 192.168.0.103 --node_certfile C:\project\private.pem --cluster_certfile C:\project\private.pem
python canonical.py

Такая конфигурация - соединение между Windows и Unix не работает по ряду причин. Я постоянно вижу подобные ошибки:

1.

Reading standard input disabled, as multiprocessing does not seem to workwith re
ading input under Windows
2018-01-03 12:50:08 dispynode - dispynode version: 4.8.3, PID: 3288
2018-01-03 12:50:08 pycos - version 4.6.5 with IOCP I/O notifier
2018-01-03 12:50:08 dispynode - "Роман-ПК" serving 2 cpus
2018-01-03 12:50:08 dispynode - TCP server at 192.168.0.101:51348
2018-01-03 12:50:08 pycos - uncaught exception in !tcp_req/36277304:
Traceback (most recent call last):
  File "C:\Program Files\Python3\lib\site-packages\pycos\__init__.py", line 3730, in _schedule
    retval = task._generator.throw(*exc)
  File "C:\Program Files\Python3\Lib\site-packages\dispy\dispynode.py", line 988, in tcp_req
    msg = yield conn.recv_msg()
  File "C:\Program Files\Python3\lib\site-packages\pycos\__init__.py", line 3732, in _schedule
    retval = task._generator.send(task._value)
  File "C:\Program Files\Python3\lib\site-packages\pycos\__init__.py", line 882,
 in _async_recv_msg
    data = yield self.recvall(n)
  File "C:\Program Files\Python3\lib\site-packages\pycos\__init__.py", line 1438, in _iocp_recvall
    self._read_result = win32file.AllocateReadBuffer(bufsize)
MemoryError

2.

Reading standard input disabled, as multiprocessing does not seem to workwith re
ading input under Windows
2018-01-03 12:54:12 dispynode - dispynode version: 4.8.3, PID: 3284
2018-01-03 12:54:12 pycos - version 4.6.5 with IOCP I/O notifier
2018-01-03 12:54:12 dispynode - "Роман-ПК" serving 2 cpus
2018-01-03 12:54:12 dispynode - TCP server at 192.168.0.101:51348
2018-01-03 12:54:13 pycos - uncaught exception in !tcp_req/36342840:
Traceback (most recent call last):
  File "C:\Program Files\Python3\lib\site-packages\pycos\__init__.py", line 3730, in _schedule
    retval = task._generator.throw(*exc)
  File "C:\Program Files\Python3\Lib\site-packages\dispy\dispynode.py", line 988, in tcp_req
    msg = yield conn.recv_msg()
  File "C:\Program Files\Python3\lib\site-packages\pycos\__init__.py", line 3732, in _schedule
    retval = task._generator.send(task._value)
  File "C:\Program Files\Python3\lib\site-packages\pycos\__init__.py", line 882,
 in _async_recv_msg
    data = yield self.recvall(n)
  File "C:\Program Files\Python3\lib\site-packages\pycos\__init__.py", line 1438, in _iocp_recvall
    self._read_result = win32file.AllocateReadBuffer(bufsize)
OverflowError: Python int too large to convert to C long

3.

2018-01-03 12:59:54 dispyscheduler - dispyscheduler version 4.8.3
2018-01-03 12:59:54 pycos - version 4.6.5 with epoll I/O notifier
Enter "quit" or "exit" to terminate scheduler, anything else to get status: 2018-01-03 12:59:54 dispyscheduler - Scheduler at 192.168.0.103:51349
2018-01-03 12:59:54 dispyscheduler - TCP server at 127.0.1.1:51347
2018-01-03 12:59:54 dispyscheduler - TCP server at 192.168.0.103:51347
2018-01-03 12:59:54 dispyscheduler - Scheduler at 127.0.1.1:51349
2018-01-03 12:59:54 pycos - uncaught exception in !tcp_req/139968956623560:
Traceback (most recent call last):
  File "/home/dismine/project/env/lib/python3.5/site-packages/pycos/__init__.py", line 3730, in _schedule
    retval = task._generator.throw(*exc)
  File "/home/dismine/project/env/bin/dispyscheduler.py", line 368, in tcp_req
    msg = yield conn.recv_msg()
  File "/home/dismine/project/env/lib/python3.5/site-packages/pycos/__init__.py", line 3730, in _schedule
    retval = task._generator.throw(*exc)
  File "/home/dismine/project/env/lib/python3.5/site-packages/pycos/__init__.py", line 868, in _async_recv_msg
    data = yield self.recvall(n)
  File "/home/dismine/project/env/lib/python3.5/site-packages/pycos/__init__.py", line 461, in _recvall
    recvd = self._rsock.recv_into(view, len(view), *args)
  File "/usr/lib/python3.5/ssl.py", line 929, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.5/ssl.py", line 791, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib/python3.5/ssl.py", line 575, in read
    v = self._sslobj.read(len, buffer)
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1977)

К сожалению, моих навыков недостаточно, чтобы понять, что не так с дисплеем или моими настройками. Почему в случае использования только системы Unix или только систем Windows это работает, но не вместе.

Я также представил вопрос на GitHub.

0 ответов

Другие вопросы по тегам