« first day (962 days earlier)      last day (3989 days later) » 

3:02 PM
I still don't know what you mean by that.
I think your terminology is off.
 
Zac
who me ?
 
4
Q: Non-blocking socket in Python?

ultimatebusterIs it me, or can I not find a good tutorial on non-blocking sockets in python? I'm not sure how to exactly work the .recv and the .send in it. According to the python docs, (my understanding of it, at least) the recv'ed or send'ed data might be only partial data. So does that mean I have to some...

0
Q: Non Blocking Server in Python

felixCan someone please tell how to write a Non-Blocking server code using the socket library alone.Thanks

Did you even look at SO at all?
There are MANY results when I search "non blocking socket server in python"
 
Zac
non of them address my issue
 
You have not so far informed me to what it is.
Because those seem to address just what you said.
 
Zac
I posted it above
0
Q: How to implement non blocking socket server in python

ZacA similar but different question: I have an IRC client that generates strings. This IRC client uses a hook to call a method (somone_said) whenever someone says something. I want to send this string over a socket to my flash client. I have a working client in flash and a server in python but the...

 
3:05 PM
Okay, first of all. That is the worst question I have possibly seen on SO ever (just kidding) but seriously man, your question is all over the place. You spend the first 5 paragraphs explaining something that makes no sense to anyone but you and that is not even the problem.
You need to refine you question down to the essential.
No one cares about the rest of your code, or what a great idea it is. You have a question about getting your sockets working. Ask that.
There is too much JUNK around your question to understand anything
 
Zac
I have a working socket that isn't the problem
the problem is the context of the python IRC client
 
So then "How to implement non blocking socket server in python" Is a HORRIBLE title
 
I am creating a dicitionary as follows
>>> p=[('name','Throatwobbler'),('age',42),('name','Mangrove'),('age',42)]
>>>person=dict(p)
 
Zac
it needs to not pause my program execution while waiting to listen or while waiting to send
 
Where is your code not working. What is not happening?
So ask about that.
 
3:07 PM
but when I do >>> person
 
Zac
I did
 
I just see following output {'age': 42, 'name': 'Mangrove'}
 
@Zac try looking for asynchronous python chat server or something along those lines
 
rest of the values are missing what mistake I did here
 
@RegisteredUser What are you expecting to see
 
3:08 PM
complete dictionary
 
It is
You are overiding the previous entries
If is say to you
a = 1
 
Zac
I just need my python chat IRC client to send strings to a port when it recieves them
 
and then
I say,
a = 2
what is a ?
 
In your dict, you give a value for 'name' and then 'name' again.
So it replaces the old one.
 
3:09 PM
ok so dict function
is useless in that case
I want to create a dictionary with many names and ages
 
@Zac Asynchronous is the key word here
 
Zac
The problem is the program hangs while waiting for a client connection and between strings sends
 
Maybe you want:
people = [{'name': 'Throatwobbler', 'age': 42}, {'name': 'Mangrove', 'age': 42}]
A list of dictionaries.
 
person = dict([('name','Throatwobbler'),('age',42),('name','Mangrove'),('age',42)]) or person = {'name': 'Throatwobbler', 'age': 42, 'name': 'Mangrove', 'age': 42}
this is the proper sytax
 
No
That is wrong @PeterVaro
 
3:11 PM
but as @InbarRose mentions, you can create list of dictionaries
 
person = {'name': 'Throatwobbler', 'age': 42, 'name': 'Mangrove', 'age': 42} is wrong.
You are overriding 'name' and 'age'
 
OOOHHH
that's right
I didn't noticed that
:P
 
@Zac that is not a problem. That is what it is supposed to do.
 
Since I never create dictionaries like this
 
When you have one thread/process running, it can only do 1 thing at a time, when you tell it to connect using sockets, it will wait until that action is done before continuing.
You need multiple threads/processes
 
Zac
3:13 PM
can you suggest how I do that
 
I am having a class which access person[name] from the available values in a dictionary so the thing you mentioned a list of dictionaries is that the right way?
 
Zac
From my question : I think I need to create my socket in a separate thread but this creates three more problems. 1) how does my someone_said event driven method access the socket 2) What if someone says something when there is no server client connection (while listening) or if the client has closed the connection. 3) How to check if the thread is alive and if not to open a new one?
 
@RegisteredUser yes.
 
ok thnks
 
@Zac Use a Queue, and use a Daemonic thread.
 
Zac
3:17 PM
I think my code already has demons in it
 
You can read all about how Threads and Multiprocessing works.
(full disclosure, all I did to get those links was google "Python threading" and "Python multiprocessing" - any idiot could have done it)
 
Zac
have I angered you in some way ? I'm sorry I didnt mean to piss you off
 
Am i allowed to post a question of my in the main SO website
Or is that against the ruleS?
 
You just refuse to learn. Instead you ask a question, and assume you know exactly what the problem is, and wait for the answer to fall into your lap. Instead of going out and searching, or figuring out why what you are doing is not working or getting another method to do it. I see all your question history, I see this is how you are doing things. It is not conducive to learning anything.
 
Zac
but thanks for googling that and sending me those links I've already read, you've been really helpful
 
3:21 PM
If you had presented your question properly, this would have all been different.
 
Zac
Im' sorry again if I have offended you, I'm a biochemist who is trying to learn a mixture of C++, Java, python, arduino wiring and actionscript. I'm not a programmer
 
I totally understand that. And I am not angry at you, only disappointed.
You fall into the pattern of relying on SO to solve your problems.
 
Zac
I'm trying to learn from helpful people and telling me to google is about as helpful as you can get
 
You totally give up on it being your lack of knowledge, and you tackle the issues with your limited experience and assuming that you know what needs to be fix
This whole time you are trying to figure out how to make a non-blocking socket. Where that is NOT EVEN THE PROBLEM
 
Zac
do you really think I haven't googled python sockets, blocking and every term I can think of I have spent hours reading other peoples code
 
3:23 PM
That is the problem
You have not spent enough time reading about Python, and how to do things. Instead you look for answers to what you think is the problem
 
Zac
So please tell me what you think I should be doing ?
 
Learning how to use threads.
SO that you can perform asynchronous actions.
which will solve most of your problems.
how about thread pools?
 
@mgilson you are always a few milisec faster than I am :( #Last time: Py2.4 String formatting
 
Zac
As simple as just learning threads... just like that. So having learnt' threads you know the answer to my problem but you'd rather not tell me but you think I need to work it out myself ?
 
AHH BLOODY PYTHON QUEUES
 
3:25 PM
One pool for reading, one for writing, and the rest for reading.
I already told you the 'answer' to your problem is to use threads.
I am not going to write it for you.
 
Zac
wow you are the most helpful person I have ever met
 
I am glad you think that (ignore sarcasm completely)
 
Peaches and Pears, chill please :(
 
Zac
depite me writting in my question, that you clearly took time to read : I think I need to create my socket in a separate thread but this creates three more problems. 1) how does my someone_said event driven method access the socket 2) What if someone says something when there is no server client connection (while listening) or if the client has closed the connection. 3) How to check if the thread is alive and if not to open a new one?
but thanks for telling me I need to use threads
How would I have know that if not for you
 
You are the one getting bent out of shape and upset because some 'stranger' on the internet is trying to help you, (and not for the first time) on a problem that you have given up trying to solve.
 
Zac
3:27 PM
please tell me to google threads again
you haven't helped me at all you've just antagonized me because I don't know how to implement a non blocking socket in a thread
 
Artichoke?
 
Zac
and you've pointed me at the first google result for python threads
thanks for that
 
@Zac stop being a douchebag
a person tries to help and gives you useful links maybe his method of help is not your way of understanding what help is but the fact is that he spent time actually replying to your questions
....
 
Zac
@MaxPower I appreciate that but really if he hasn't got anything helpful other than "google the question yourself" to say then way say anything ?
 
@Zac yet you totally ignored "When you have one thread/process running, it can only do 1 thing at a time, when you tell it to connect using sockets, it will wait until that action is done before continuing.
You need multiple threads/processes"
 
3:32 PM
Zac, you have been coming here for days and I and others have been helping you on the same bunch of code, all in different questions.
 
Zac
None of the answers have fixed the issue
 
Lol do you think people work for you or something?
 
At what point do you realize that you just need to start reading the manuals, and the tutorials. How do you think we learned anything? I didn't hang around chat-rooms asking for help. I read the tutorials, and the guides and etc..
 
seriously dude
 
cabbage folks
 
Zac
3:34 PM
Sorry I thought this was a chat room where people ask for help ?
 
Cabbage Zod.
It is.
It is not where you commission work.
 
Zac
commission work ?
 
Solicit others to do your work, or write your code for you.
 
Zod? is that new
 
@Kneel-Before-ZOD <- zod.
 
Zac
3:35 PM
Asking for help with my programming problem is comissioning work ?
 
Ohh damnit, i thought you created an additional word to salad
 
nope.
 
@HarryBeasant I am ZOD :)
 
Zac
I'm not getting paid for this chat app I'm trying to make it for myself and friends to use for free
 
@Zac No. but you have stopped asking for help, and are asking for solutions.
Help is a nudge in the right direction, often times it is a link.
I do not know that you read those links.
Those are the links that PROVIDE the solution
If you did read them - you should have the solution.
 
Zac
3:37 PM
so you want me to jump though hoops ? Because I'm not struggling enough ?
 
What hoops?
 
Zac
I've read them to the best of my ability yes
I read those particular links days ago
 
This is the real world, you want to do X. you can't presume to be able to do that if you only got as far as F. you need to start progressing.
 
Zac
Im' a biochemist not a programmer I'm trying here
 
Exactly
Programming is not something you can do in 1 week
You need to learn it. It takes time
 
Zac
3:38 PM
I'm trying really hard to understand several different languages to achieve tasks
 
The solution to what you are trying to do is using threads.
That means you have to learn it
 
Zac
I set out with a task and I try to get it to work
 
Good. So try. Don't give up and spend hours looking for solutions to 'your exact problem'
You need to break it down into its subsystems. Just like in biochemistry. Each "whole" system is built of smaller ones
 
Zac
Look at my previous questions, I needed to communicate via RS232 to a peristatlic pump. I didn't know how to do it so I tried C++ and Java after weeks I got it working
 
Your "chat" program has many elements.
The element that you need help on is getting it to be asynchronous.
That is achieved with Python through Threading, and MultiProcessing.
For me to start giving you lessons here, or built solutions is ridiculous. So go research and figure it out. What else would you call that, then help?
 
3:40 PM
none of my business, but I gotta ask outta curiosity: why is a biochemist trying to help non-programming friends with a programming app?
 
Zac
that is just one example of a problem I needed to get working. I'm sorry if asking for solutions is a bad thing because I need to learn the entire language before it is acceptable for you to help me out
 
No
Not at all
But my help comes at the expense of you having to learn.
I am sure that you did not get to be a biochemist by copying the answers from friends.
 
Zac
I thought I was learning, but clearly my method of asking for help offends you
 
So start digging in to the material.
If you are struggling, back out and learn more basic things.
Many people who know NOTHING about programming think it will be a piece of cake "How hard can it be to make a COD4-like game?"
Just because you want to do something, and have an idea of how it should work -doesn't mean you actually can do it
 
HARD
 
3:43 PM
You have to start with the BASICS and work your way up.
You have a prestigious task. It will not be easy. My help to you is that you should use threading and etc... if you already knew that.. why did you ask the question?
 
@InbarRose that's kinda the point of my question; if you are building an app because you like to, you must be ready to do what programmers do: learn the stuff
 
@PeterVaro @PeterVaro -- FGITW :)
 
@InbarRose @InbarRose I hear asyncronous is
cleaner
 
huh?
 
3:45 PM
:9805145
^It should link no?
 
So…apparently I have no idea how to install gtk or whatever so I can "import gobject" in a python document using eclipse. I've (embarassingly) spent the better of two days trying to figure it out, and everything I've tried hasn't worked. I'd REALLY appreciate some help.

An extra tidbit, this goes a LONG way to helping me graduate college. I'm graduating at the end of this month, but really need this to finish my project. Thanks in advance!
 
:9805179
@Xeon only if you supply some text as well
 
Ugh, sorry. I just saw you wrote "you should use threading" and tried to make the point that someone wrote to me that asynchronous programming, when referring to a chat program was better. I don't know if it's true, it's just what I was told.
 
Yuck, eclipse. pip install pygtk should usually work if you have a sane (non-windows) environment
 
Been there done that
I tried it using MacPorts though
 
3:47 PM
@ThiefMaster -- I remember a few months ago I had huge issues trying to install it on OS-X (I don't actually remember how I fixed it though)
@jpcguy89 -- So you're on OS-X?
:-/
 
Yup -.-
 
I am going to ask the stupid question: did you restart?/uninstall+reinstall/check latest versions/check matching versions?
 
yessir
 
I'm assuming you also tried easy_install
 
Okay, so then which tutorial/guide did you follow?
 
3:48 PM
I was going to. Then I ran into a conflict with macPorts
 
made sure you are using the right version? (32/64 bit)
 
I very much dislike macPorts and pretty much gave up trying to use it for anything :-) (But, I have very little patience for package managers which don't manage my packages in the way that I want them to)
 
The better question is what guide DIDN'T I try.
Why is it so complicated to install one module?
 
It is not.
 
3:50 PM
Oh.
 
You just did something wrong somewhere
Or forgot something
Or overlooked something
It is something very trivial that you are going to slap yourself over.
a module is really just a collection of files, you can technically put it in place manually.
 
is there a way around the single call to gobject.threads_init()
 
I am not familiar with the module.
 
You'd think I'd be better with this, given I'm a Software Engineering Major. 0.o
 
indeed.
Did you check all the requirements, and prerequisites?
update all your software etc?
 
3:53 PM
Yes.
 
Have you considered Linux? :P
 
I have an idea, but I'm not sure. I installed from my named home directory
Is that a problem?
 
I am not familiar with OSX
 
Should I have installed from usr/bin/local or some other location
 
That should not make a difference.
But you should be consistent
And that is not always the case with some software which assumes defaults.
 
3:55 PM
Okay. Is there a way I can check to see if the module is installed properly? Let's say it were windows. How would you do it?
 
I would just purge and try it all again with a clean slate.
modules aren't really 'installed'
they are just files in directories
 
:)
 
when you 'import' it looks in the sys.path
 
Just saw this
[1] Rerun phase build
[2] Ignore error and continue to install
[3] Give up on module
[4] Start shell
[5] Reload configuration
[6] Go to phase "wipe directory and start over"
[7] Go to phase "configure"
[8] Go to phase "clean"
[9] Go to phase "distclean"
 
uh?
okay.
That won't help.
 
3:57 PM
Are you sure?
It's GTK
 
Well, try it.
What can I say.
 
Which one? lol
 
Except for that I must leave.
Rhubarb everyone.
 
Ack. Okay. Thanks for your help.
 
@InbarRose rhubarb to you
 
4:23 PM
Quick Q
Lets i have two modules
One that adds queues and processes them and one that does other stuff and calls the add queue function
Actually
might be best if you see this; stackoverflow.com/questions/16920433/…
How can i have the same instance of a class on two models?
 
 
1 hour later…
5:41 PM
cabbagiousness
 
Cabbage
 
hey :)
 
 
1 hour later…
6:43 PM
I am always here.
Just-lurking.
 
Guys if i call a job from a queue
but running the data isnt successful
how can i like place the item back in the queu
Just to put again
?
 
@Harry Beasant: not sure what you're asking, but couldn't you put the data back in the queue? Perhaps some more context?
 
Yeah i thought that
Basically i call the queue.get()
 
Yes, what is a "job" in this context?
 
The better question is 'should you'
 
6:50 PM
say i use the data and put it into a database
database query fails
So i dont call task_done?
Or i do call task done and place it back into the queu
 
I guess my question still remains. Technically you probably could do that (I'd have to refresh myself on queues in python) but if the data is failing, should you be attempting to run it again?
 
What's task_done? Are you using only built-in modules? Because you're using terminology I'm not familiar with.
 
Ditto.
In you previous example, I suppose it would also depend on what 'database query fails' means. Thrown Exception? Simply no data returned? Unexpected resultant behavior?
 
queue.task_done()
Tells the queue that that particular task is done
Its Python queues, no extra modules
On built in ones
 
Grr, I was going to actually check the documentation on queues but I can't access it behind my company's firewall because python is 'shareware and freeware'
Stupid firewall
 
6:55 PM
You know, I've used queues dozens of times and I never noticed task_done exists.
Never used it.
Strange.
 
Surely its protocol to call task_done?
But thinking about it, it didnt make a difference
the queue job was always removed anyway
 
Seems to me that you should put the task back in the queue, and then call task_done. If you do it in the opposite order, there could be a brief moment where the queue appears to be empty, even though the final task failed and will shortly be reinserted.
It might mislead workers into thinking that their job is done and that they can terminate themselves.
If you think of the task as "attempt to put the data in the database", then the task is done after the query executes, regardless of whether the query succeeded or not. On a failure, you might like to add a new task to the queue, but that's irrelevant to the question of whether this task is done.
 
7:19 PM
If i use self before an object
What does that do to it
 
self is an instance of a class. In particular, the class whose definition contains the function you are in.
So if you're inside def frob(self), which is inside class Fred, then self.foo accesses the foo member of the instance of the Fred class.
The tutorial has a section talking about classes and self.
 
frob?
you mean foo
 
Ex:
class Fred:
    def __init__(self):
            self.foo = 23
    def frob(self):
            return self.foo

f = Fred()
print f.frob()
Result: 23
print f.foo would likewise give 23.
The members of a class instance are localized to that instance only. Multiple instances of a class can have different values for the same member. Ex:
class Widget:
    def __init__(self, name):
        self.name = name

a = Widget("Alice")
b = Widget("Bob")
c = Widget("Carol")
print a.name, b.name, c.name
Result: Alice Bob Carol
 
Hmm okay
I think i see
THanks
Im having trouble getting a queue to share itself with the rest of the class
If i specify it like so
def __init__(self):

    self.process = QP()
    self.jobs = Queue.Queue()
Surely that can then be access by any function like foo(self)
 
7:38 PM
Sure, in any method defined within that class, whose first argument is self
 
What about accessing other function from modules you import
I do this
from QueueProcessing import QP
process = QP()
if process.processQueue(data) == True:
 
Looks good to me.
 
And thats within the function
def runQueue(self)
I get
AttributeError: trackUDP instance has no attribute 'process'
 
Style point: never compare something to a literal boolean value. Using if process.processQueue(data): instead of if process.processQueue(data) == True:.
 
Hmm, I don't see any code that would cause that error. I'd expect that error if you had something.process, but not if you had process.something
 
7:52 PM
Oh okay thanks
Im getting strange errors on this
You mind if i pastebin it to you?
 
I can look at it in the 300 seconds I have left before I go.
 
Oh... the joy of having to deal with legacy code...
 
iterlists -- that's a new one to me.
gotta go, later
 
@ThiefMaster that looks like fun ;)
 
8:20 PM
Hi
I am confused - timeit.timeit("test()", setup="from main import test") returns result in SECONDS or MILISECONDS ?
for my Bubble Sort function (for 1000 items) it returns 0.505674002155
so if result is in SECONDS it is too much ... :-)
 
It is seconds, but it's also running your code a million times.
 
yes I Know
print (timeit.timeit("BubbleSorter(random_numbers[:]).sort()", setup="from __main__ import BubbleSorter, random_numbers", number=100)/100)
so not good... my bubble sort is sloooooow
 
Being slow is all bubble sorts are good for. They're basically a fancy busy-wait.
 
but 0.5 second ? it is stretching it ;)
 
8:35 PM
I have a question which in need some advice to answer
I am creating a tool that logs certain statistics from a server
And i would like it to continue to if the database goes down
And queue the data
Then when the database is back, it will run through it all
Is that the best way of doing it, or should i store the data in pickle or json or what?
 
Probably would depend on how much data you are logging and how long the server might be down for - basically if it matters that you keep the queue in memory or not.
 
Few thousand key dictonary
 
*database
 
8:50 PM
If it's going into a database eventually, you might as well put it in one locally in the interim.
Bonus points if the database you're using provides a convenient way of merging the two.
 
interim?
 
In the meantime.
 
Locally how though
What method
pickle? JSON?
Queue?
 

« first day (962 days earlier)      last day (3989 days later) »