boostorg / boostorg/python

Beast Socket from Boost Python Package Kills Kernel

未關閉
#448 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C++
星號
537
分支
223
平均合併
11 小時 22 分鐘
30 天內合併 PR
2

描述

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
#include
#include
#include

//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>;
public:
SocketExample()
{
}

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

private:
std::unique_ptr m_ws;
};

//ExampleModule
#include

BOOST_PYTHON_MODULE(ExampleModule)
{
boost::python::class_, 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
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。