pub struct SharedSocket { /* private fields */ }
Expand description
Socket implementation that can be shared between multiple Python processes.
Python cannot handle true multi-threaded applications due to the GIL, often resulting in reduced performance and only one core used by the application. To work around this, Python web applications usually create a socket with SO_REUSEADDR and SO_REUSEPORT enabled that can be shared between multiple Python processes, allowing you to maximize performance and use all available computing capacity of the host.
Implementations
sourceimpl SharedSocket
impl SharedSocket
sourcepub fn new(address: String, port: i32, backlog: Option<i32>) -> PyResult<Self>
pub fn new(address: String, port: i32, backlog: Option<i32>) -> PyResult<Self>
Create a new UNIX SharedSocket
from an address, port and backlog.
If not specified, the backlog defaults to 1024 connections.
sourcepub fn try_clone(&self) -> PyResult<SharedSocket>
pub fn try_clone(&self) -> PyResult<SharedSocket>
Clone the inner socket allowing it to be shared between multiple Python processes.
sourceimpl SharedSocket
impl SharedSocket
sourcepub fn get_socket(&self) -> Result<Socket, Error>
pub fn get_socket(&self) -> Result<Socket, Error>
Get a cloned inner socket.
Trait Implementations
sourceimpl Debug for SharedSocket
impl Debug for SharedSocket
sourceimpl IntoPy<Py<PyAny>> for SharedSocket
impl IntoPy<Py<PyAny>> for SharedSocket
sourceimpl PyClass for SharedSocket
impl PyClass for SharedSocket
type Dict = PyClassDummySlot
type Dict = PyClassDummySlot
Specify this class has #[pyclass(dict)]
or not.
type WeakRef = PyClassDummySlot
type WeakRef = PyClassDummySlot
Specify this class has #[pyclass(weakref)]
or not.
type BaseNativeType = PyAny
type BaseNativeType = PyAny
The closest native ancestor. This is PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
. Read more
sourceimpl PyClassImpl for SharedSocket
impl PyClassImpl for SharedSocket
sourceconst DOC: &'static str = "Socket implementation that can be shared between multiple Python processes.\n\nPython cannot handle true multi-threaded applications due to the [GIL],\noften resulting in reduced performance and only one core used by the application.\nTo work around this, Python web applications usually create a socket with\nSO_REUSEADDR and SO_REUSEPORT enabled that can be shared between multiple\nPython processes, allowing you to maximize performance and use all available\ncomputing capacity of the host.\n\n[GIL]: https://wiki.python.org/moin/GlobalInterpreterLock\u{0}"
const DOC: &'static str = "Socket implementation that can be shared between multiple Python processes.\n\nPython cannot handle true multi-threaded applications due to the [GIL],\noften resulting in reduced performance and only one core used by the application.\nTo work around this, Python web applications usually create a socket with\nSO_REUSEADDR and SO_REUSEPORT enabled that can be shared between multiple\nPython processes, allowing you to maximize performance and use all available\ncomputing capacity of the host.\n\n[GIL]: https://wiki.python.org/moin/GlobalInterpreterLock\u{0}"
Class doc string
sourceconst IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
#[pyclass(subclass)]
sourceconst IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
#[pyclass(extends=…)]
sourceconst IS_MAPPING: bool = false
const IS_MAPPING: bool = false
#[pyclass(mapping)]
type Layout = PyCell<SharedSocket>
type Layout = PyCell<SharedSocket>
Layout
type ThreadChecker = ThreadCheckerStub<SharedSocket>
type ThreadChecker = ThreadCheckerStub<SharedSocket>
This handles following two situations: Read more
fn for_all_items(visitor: &mut dyn FnMut(&PyClassItems))
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
fn py_methods(self) -> &'static PyClassItems
sourceimpl PyTypeInfo for SharedSocket
impl PyTypeInfo for SharedSocket
type AsRefTarget = PyCell<SharedSocket>
type AsRefTarget = PyCell<SharedSocket>
Utility type to make Py::as_ref work.
sourcefn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
PyTypeObject instance for this type.
sourcefn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
Checks if object
is an instance of this type or a subclass of this type.
sourcefn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
Checks if object
is an instance of this type.
Auto Trait Implementations
impl RefUnwindSafe for SharedSocket
impl Send for SharedSocket
impl Sync for SharedSocket
impl Unpin for SharedSocket
impl UnwindSafe for SharedSocket
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> PyTypeObject for T where
T: PyTypeInfo,
impl<T> PyTypeObject for T where
T: PyTypeInfo,
sourcefn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
Returns the safe abstraction over the type object.
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more