Beast Socket from Boost Python Package Kills Kernel

Offen
#448 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
cpp, jupyter-notebook
Bereich
api, backend

Rechercherichtung

Beginne mit dem im Issue gezeigten Code von SocketExample und ExampleModule und reproduziere dann den Fehler, indem du ExampleModule im Jupyter-Beispiel importierst und constructSocket aufrufst. Vergleiche dieses Verhalten mit demselben Aufruf von SocketExample aus main.cpp; abgeschlossen ist die Aufgabe, wenn der Jupyter-Kernel weiterläuft und die Socket-Erstellung abgeschlossen wird, ohne ihn zu beenden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
Vorherrschende Sprache
C++
Sterne
537
Forks
223
Ø Merge
11 Std. 22 Min.
Gemergte PRs (30 T.)
2

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus boostorg/python

Alle Issues in boostorg/python

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.