Beast Socket from Boost Python Package Kills Kernel

オープン
#448 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp, jupyter-notebook
領域
api, backend

調査の方向性

Issueに示されているSocketExampleとExampleModuleのコードから始め、Jupyterの例でExampleModuleをimportしてconstructSocketを呼び出すことで失敗を再現します。その動作を、main.cppから同じSocketExampleの呼び出しを行った場合と比較します。完了条件は、Jupyterカーネルが実行中のままになり、ソケットの構築がカーネルを終了させずに完了することです。

索引モデルが issue の本文から書いたものです。

説明

For some reason when exposing the below to python using Boost Python, the unique pointer constructor (the obj constructor) fails. This used to work for me before, not sure why it stopped.

#pragma once
#include <memory>
#include <boost/asio/ssl.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/beast.hpp>

//Socket
class Contextable
{
public:
	Contextable() : m_ssl(boost::asio::ssl::context::sslv23_client) {}

protected:
	boost::asio::io_context    m_ctx;
	boost::asio::ssl::context  m_ssl;
};

class SocketExample : protected Contextable
{
	using SocketImp = boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>;
public:
	SocketExample()
	{
	}

	void constructSocket()
	{
		m_ws = std::make_unique<SocketImp>(m_ctx, m_ssl); //kills jupyter kernel
		std::cout << "DONE. OPEN FLAG: " << m_ws->is_open() << std::endl;
	}

private:
	std::unique_ptr<SocketImp> m_ws;
};

//ExampleModule
#include <boost/python.hpp>

BOOST_PYTHON_MODULE(ExampleModule)
{
    boost::python::class_<SocketExample, std::shared_ptr<SocketExample>, boost::noncopyable>("SocketExample")
        .def(boost::python::init<>())
        .def("constructSocket", &SocketExample::constructSocket)
        ;
}
##Jupyter Notebook
import ExampleModule as m
socket = m.SocketExample()
socket.constructSocket() ##kills kernel

Any idea what I am doing wrong? When running this using c++ as follows does not fail.

SocketExample sk;
sk.constructSocket(); //works fine when run inside main.cpp
主要言語
C++
スター
537
フォーク
223
平均マージ
11時間 22分
マージ済み PR(30日)
2

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/python のほかの issue

boostorg/python の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。