-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running the PythonClient Throws a Compilation Error #41
Comments
I think there was a regression on main after #40 , I should definitely add a proper test suite to run in the CI to know when this happens... The code below, similar to how you tried it before, should now work. Don't forget to pull the latest changes. Will add the example code for running the client to the README.
|
I tried running this code, but it's behaving very strange. This is using the pkg file from the latest release from lightbug_http.http import HTTPRequest fn test_request_simple_url(inout client: MojoClient) raises -> None:
"""
Test making a simple GET request without parameters.
Validate that we get a 200 OK response.
"""
var uri = URI("http://httpbin.org/status/200")
var request = HTTPRequest(uri)
var response = client.do(request)
# print status code
print("Response:", response.header.status_code())
# print various parsed headers
print("Header", response.header.content_length())
# print body
print(String(response.get_body()))
fn main() raises -> None:
var client = MojoClient()
print("Testing URL request")
test_request_simple_url(client)
print("Done") This is the output I get:
It's not even printing anything for some reason in the test function |
@Logan9312 hmm I see, cannot reproduce this one on my Mac M1 using this latest package. Will try on a Linux machine later today. |
@Logan9312 hmm, couldn't reproduce on Linux as well. Could you share more details about your setup? Can you maybe try removing everything and creating a clean setup with the latest package + code you shared? Will appreciate anything that can help reproduce this. Thanks! |
Added a section in the README on using the client, see here: https://github.com/saviorand/lightbug_http?tab=readme-ov-file#using-the-client |
Using the package you linked here, I downloaded it and put it into the top level alongside a main.🔥 file. The main file only contained the code you put in the README: from lightbug_http.http import HTTPRequest
from lightbug_http.uri import URI
from lightbug_http.sys.client import MojoClient
fn test_request(inout client: MojoClient) raises -> None:
var uri = URI("http://httpbin.org/")
var request = HTTPRequest(uri)
var response = client.do(request)
# print status code
print("Response:", response.header.status_code())
# print various parsed headers
print("Header", response.header.content_length())
# print body
print(String(response.get_body()))
fn main() raises -> None:
var client = MojoClient()
test_request(client) My setup is on an M2 Macbook air. Mojo version is When running by doing
|
Ah, I see. Thanks for the details. Was able to reproduce now after switching to the nightly version. I'll try to debug but in the meantime switching to the latest stable version ( |
I got that version when running |
@Logan9312 Can you try with this version? https://github.com/saviorand/lightbug_http/releases/tag/nightly-2805 |
@saviorand Sorry for late response, but I tried that package and still get the following errors: /Users/logan/Documents/MojoTesting/lightbug_http.mojopkg:0:0: error: expected M::KGEN::LIT::DocStringAttr, but got: #kgen.symbol.constant<@lightbug_http::@http::@HTTPRequest::@"__del__(lightbug_http::http::HTTPRequest)"> : !kgen.signature<!lit.signature<[1]("self": !lit.ref<@lightbug_http::@http::@HTTPRequest, mut *[0,0]> owned_in_mem, |) -> !kgen.none>>
/Users/logan/Documents/MojoTesting/lightbug_http.mojopkg:0:0: error: expected M::KGEN::LIT::DocStringAttr, but got: #kgen.symbol.constant<@lightbug_http::@uri::@URI::@"__del__(lightbug_http::uri::URI)"> : !kgen.signature<!lit.signature<[1]("self": !lit.ref<@lightbug_http::@uri::@URI, mut *[0,0]> owned_in_mem, |) -> !kgen.none>>
/Users/logan/Documents/MojoTesting/lightbug_http.mojopkg:0:0: error: expected M::KGEN::LIT::DocStringAttr, but got: #kgen.symbol.constant<@lightbug_http::@sys::@client::@MojoClient::@"__del__(lightbug_http::sys::client::MojoClient)"> : !kgen.signature<!lit.signature<[1]("self": !lit.ref<@lightbug_http::@sys::@client::@MojoClient, mut *[0,0]> owned_in_mem, |) -> !kgen.none>> Seems like it doesn't even print the body. I'm wondering if this is maybe just a bug with mojo itself independent of the library? |
Removed the PythonServer and PythonClient in #61 due to this issue. If there's enough interest for a Python-based implementation can write a new one from scratch later |
As reported by Logan
logan100
on Discord:Describe the bug
An error is thrown when trying to run the
PythonClient
, sending a request tohttpbin
:To Reproduce
Run the client like below
Expected behavior
The client should make a successful request to the endpoint specified and receive a response.
The text was updated successfully, but these errors were encountered: