Beast Socket from Boost Python Package Kills Kernel
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the SocketExample and ExampleModule code shown in the issue, then reproduce the failure by importing ExampleModule in the Jupyter example and calling constructSocket. Compare that behavior with the same SocketExample call from main.cpp; done means the Jupyter kernel remains running and the socket construction completes without terminating it.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- C++
- Stars
- 537
- Forks
- 223
- Avg merge
- 11h 22m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/python
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
BoostDetectToolset-1.90.0.cmake file not found in an include() call in boost_python-config.cmake Open
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo-graphs#74 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 88/100
QuantStack/git2cpp#187 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100