Skip to content

Commit

Permalink
deps
Browse files Browse the repository at this point in the history
  • Loading branch information
TcMits committed Feb 1, 2024
1 parent a1d1f18 commit 45b08bd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
http = "1.0.0"
lazy_static = "1.4.0"
pyo3 = "0.19.0"
pyo3-log = { version = "0.8.1"}
pyo3 = "0.20.2"
pyo3-log = { version = "0.9.0"}
log = { version = "0.4.17" }
tokio = { version = "1.32.0", features = ["net", "signal", "rt", "macros", "io-util"] }
hyper = { version = "1.0.1", features = ["server", "http1"] }
hyper = { version = "1.1.0", features = ["server", "http1"] }
http-body-util = "0.1.0"
hyper-util = { git = "https://github.com/hyperium/hyper-util.git", rev = "bca85f782007de1cc72a4b0365cdfa1ef28afd5e", features = ["tokio", "http1", "server"] }
hyper-util = { features = ["tokio", "http1", "server", "service"], version = "0.1.3" }
tower = "0.4.13"
tower-http = { version = "0.5.0", features = ["limit"] }
futures = "0.3.29"
Expand Down
2 changes: 1 addition & 1 deletion src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use hyper::body::Bytes;
use hyper::Response;
use pyo3::exceptions::PyValueError;
use pyo3::ffi::{PyBytes_Check, PyList_Check, PyList_Size};
use pyo3::prelude::*;
use pyo3::types::{PyIterator, PyTuple};
use pyo3::{prelude::*, AsPyPointer};
use pyo3::{Py, PyObject};
use std::str::FromStr;
use std::sync::Arc;
Expand Down
10 changes: 8 additions & 2 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ where
let frame = frame.into_data().unwrap();
Python::with_gil(|py| -> Result<(), Error> {
let environ = environ.as_ref(py);
let input = environ.get_item(intern!(py, "wsgi.input")).unwrap();
let input = environ
.get_item(intern!(py, "wsgi.input"))
.unwrap()
.unwrap();
input.call_method1(intern!(py, "write"), (frame.as_ref(),))?;
Ok(())
})?;
Expand All @@ -118,7 +121,10 @@ where
Python::with_gil(|py| -> Result<Response<WSGIResponseBody>, Error> {
let builder = {
let environ = environ.as_ref(py);
let input = environ.get_item(intern!(py, "wsgi.input")).unwrap();
let input = environ
.get_item(intern!(py, "wsgi.input"))
.unwrap()
.unwrap();
input.call_method1(intern!(py, "seek"), (0,))?;
let wsgi_response_config = Py::new(py, WSGIStartResponse::new())?;
let wsgi_iter = rustgi
Expand Down
11 changes: 3 additions & 8 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use pyo3::{
ffi::{PyBytes_AsString, PyBytes_Size},
types::PyBytes,
AsPyPointer, Py,
};
use pyo3::{types::PyBytes, Py, Python};

pub struct PyBytesBuf(Py<PyBytes>);

Expand All @@ -16,9 +12,8 @@ impl PyBytesBuf {
pub(crate) fn chunk(&self) -> &[u8] {
// safe because Python bytes are immutable, the result may be used for as long as the reference to
unsafe {
let buffer = PyBytes_AsString(self.0.as_ptr()) as *const u8;
let length = PyBytes_Size(self.0.as_ptr()) as usize;
std::slice::from_raw_parts(buffer, length)
let py = Python::assume_gil_acquired();
self.0.as_bytes(py)
}
}
}

0 comments on commit 45b08bd

Please sign in to comment.