Skip to content
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

TypeError: WebSocketHandler.init() missing 2 required positional arguments: 'application' and 'request' #3373

Open
xiaochenJCC opened this issue Apr 27, 2024 · 7 comments

Comments

@xiaochenJCC
Copy link

use source code, cause TypeError: WebSocketHandler.init() missing 2 required positional arguments: 'application' and 'request'. Try to remove file (web.py)'s code line super().__init__() in RequestHandler.init(), it runs ok. puzzled :(

@bdarnell
Copy link
Member

It sounds like you may be inheriting from both WebSocketHandler and RequestHandler (perhaps indirectly). I've never tried that and I'm not sure if it would work or not. It might be sensitive to the order of your base classes.

@bees4ever
Copy link

please fix it

@bdarnell
Copy link
Member

bdarnell commented Aug 7, 2024

Fix what, exactly? There's not enough information here for me to tell what's going on. Can you provide a complete example of how you're using WebSocketHandler that demonstrates the problem?

@Mohankrish08
Copy link

_init
cls.init(self, *args, **kwargs)
TypeError: WebSocketHandler.init() missing 2 required positional arguments: 'application' and 'request'

still i facing this issue, how to fix this issue?

@bdarnell
Copy link
Member

Again, there's not enough information in any of the three reports here for me to tell what's going on. You'll need to provide a complete example showing how you're using WebSocket to demonstrate the problem.

@Vishwaaaah
Copy link

Vishwaaaah commented Oct 20, 2024

import pandas as pd
import numpy as np
import pickle
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.sequence import pad_sequences

model=load_model("next_word_prediction_model.h5")

with open('tokenizer','rb') as f:
    tokenizer=pickle.load(f)

def predict_next_word(model,tokenizer,text,max_sequence_len):
    token_list=tokenizer.texts_to_sequences([text])[0]
    if len(token_list)>max_sequence_len:
        token_list=token_list[-(max_sequence_len-1):]
    token_list=pad_sequences([token_list],maxlen=max_sequence_len-1,padding='pre')
    predicted=model.predict(token_list,verbose=0)
    predicted_word=np.argmax(predicted,axis=1)
    for word,index in tokenizer.word_index.items():
        if index==predicted_word:
            return word
    return None
st.title("Next Word Prediction with LSTM")
input_text=st.text_input("Enter the text","Laertes, and his")
if st.button("Predict Next Word"):
    predicted_word=predict_next_word(model,tokenizer,input_text,max_sequence_len)
    st.write("Predicted word is: ",predicted_word)

here is the code which is facing the error
TypeError: WebSocketHandler.init() missing 2 required positional arguments: 'application' and 'request'

I am using streamlit==1.35.0 and python 3.10.0 virtual environment.

hope this is enough to fix the error.
i would appreciate a response soon :)

@bdarnell
Copy link
Member

OK, so you're not using Tornado directly, but it's coming in through another package (probably streamlit)? You may have better luck on the streamlit issue tracker then; it may be specific to the way they're using WebSocketHandler. There's an open issue here: streamlit/streamlit#9140

I don't know anything about streamlit (and I can't use the code you provided because it needs a tensorflow model file to be present), so I'm not going to be much help in debugging but I did see one slightly unusual thing that I left as a comment on the streamlit issue: streamlit/streamlit#9140 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants