Re: Problems with permissions etc

2005-07-28 Thread Frank Millman
Thanks for all the replies. They were useful. I think that my situation was best summed up by Mike - I need to figure out which things I have to do as root and which I have to do as me. I guess this only comes from experience, but it seems a good rule to follow. My reasons for wanting the mac add

Buglet in win32 odbc

2005-08-11 Thread Frank Millman
more correct if it returned an int in the first place. If Mark Hammond is listening, is it possible that this can be fixed? Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

How to protect Python source from modification

2005-09-12 Thread Frank Millman
advice which helps to clarify my thinking will be much appreciated. Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: How to protect Python source from modification

2005-09-12 Thread Frank Millman
Gerhard Häring wrote: > Frank Millman wrote: > > Hi all > > > > I am writing a multi-user accounting/business system. Data is stored in > > a database (PostgreSQL on Linux, SQL Server on Windows). I have written > > a Python program to run on the client, whic

Re: How to protect Python source from modification

2005-09-12 Thread Frank Millman
Peter Hansen wrote: > Frank Millman wrote: > > I am writing a multi-user accounting/business system. Data is stored in > > a database (PostgreSQL on Linux, SQL Server on Windows). I have written > > a Python program to run on the client, which uses wxPython as a gui, &g

Re: How to protect Python source from modification

2005-09-12 Thread Frank Millman
bruno modulix wrote: > Frank Millman wrote: > > Hi all > > > > I am writing a multi-user accounting/business system. Data is stored in > > a database (PostgreSQL on Linux, SQL Server on Windows). I have written > > a Python program to run on the client, whic

Re: How to protect Python source from modification

2005-09-12 Thread Frank Millman
Steven D'Aprano wrote: > On Mon, 12 Sep 2005 08:33:10 -0700, Frank Millman wrote: > > > My problem is that, if someone has access to the network and to a > > Python interpreter, they can get hold of a copy of my program and use > > it to knock up their own client pr

Re: How to protect Python source from modification

2005-09-13 Thread Frank Millman
Dennis Lee Bieber wrote: > On 12 Sep 2005 08:33:10 -0700, "Frank Millman" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > My problem is that, if someone has access to the network and to a > > Python interpreter, they can get

Re: How to protect Python source from modification

2005-09-13 Thread Frank Millman
Bugs wrote: > As a side question Frank, how was your experiences using wxPython for > your GUI? > Any regrets choosing wxPyton over another toolkit? > Was it very buggy? > How was it to work with in general? > Any other real-world wxPython feedback you have is appreciated. >

Re: How to protect Python source from modification

2005-09-13 Thread Frank Millman
Steve M wrote: > This is a heck of a can of worms. I've been thinking about these sorts > of things for awhile now. I can't write out a broad, well-structured > advice at the moment, but here are some things that come to mind. > [snip lots of interesting stuff] Thanks for the reply, Steve. My thi

Re: How to protect Python source from modification

2005-09-13 Thread Frank Millman
Dennis Lee Bieber wrote: > On 13 Sep 2005 01:00:37 -0700, "Frank Millman" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > 2. I am a great believer in 'field-by-field' validation when doing data > > entry, instead of f

Re: How to protect Python source from modification

2005-09-13 Thread Frank Millman
Magnus Lycka wrote: [snip lots of interesting stuff] > > > There is the question of where state should be maintained. If on the > > server, I would have to keep all the client/server connections open, > > and maintain the state of all the sessions, which would put quite a > > load on the server.

Re: How to protect Python source from modification

2005-09-14 Thread Frank Millman
Magnus Lycka wrote: > Frank Millman wrote: > > I have seen Twisted mentioned many times in this ng, but I have no idea > > what it actually does. Can someone tell me in simple terms what > > advantage it might give me over a multi-threaded socket server program. > >

Re: {SPAM} start a python application as a win NT service

2005-03-15 Thread Frank Millman
http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/3b6ca01be1c70c76/1d172ee2d5c627b8?q=srvany#1d172ee2d5c627b8 I hope this comes out in a usable form - it seems rather long. If it does not work, search in google groups for 'srvany' and look for the message dated July 2004. HTH Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

How to create datetime object from DbiDate (win32.odbc)?

2005-03-17 Thread Frank Millman
how to extract the elements. Does anyone know if this is possible, and if so, how? Many thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create datetime object from DbiDate (win32.odbc)?

2005-03-18 Thread Frank Millman
Robert Brewer wrote: > Frank Millman wrote: > > > > First prize would be to have a datetime constructor that takes a > > DbiDate object as input, in the same way that mx does, but this does > > not seem to exist. > > Try: > > datetime.datetime.utcfromtimest

Best way to create temporary file?

2005-04-29 Thread Frank Millman
nistrators group. Any advice on the best approach for this will be much appreciated. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Showing Progress Bar

2013-11-23 Thread Frank Millman
set() Before starting the copy - progress_bar = ProgressBar() progress_bar.start() When the copy is finished - progress_bar.stop() progress_bar.join() HTH Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

sys.stdout and Python3

2013-11-23 Thread Frank Millman
I could not see the reason for the above behaviour. Is there a way to reproduce the Python2 behaviour in Python3 using sys.stdout? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

A cautionary tale

2013-12-04 Thread Frank Millman
that change, done some more testing, and for now it seems ok. So have the last couple of days been a waste of time? I don't think so. Is the program a bit cleaner and conceptually sounder? I hope so. Why am I telling you all this? No particular reason, just thought some of you migh

Re: A cautionary tale

2013-12-05 Thread Frank Millman
"Steven D'Aprano" wrote in message news:52a033f5$0$2$c3e8...@news.astraweb.com... > On Wed, 04 Dec 2013 11:16:40 +0200, Frank Millman wrote: > > [...] >> Then I noticed that certain changes were not being written back to the >> database. After some invest

Re: New to Python, Help to get script working?

2013-12-16 Thread Frank Millman
can help. BTW, did you notice that I removed the bulk of your original message, and left behind just enough to provide a context for your question and for my reply? This is good etiquette, and others will appreciate your doing the same. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Python mange with liste

2013-12-29 Thread Frank Millman
. In the previous version, message is set to 'wrong' for every iteration of the loop until a valid name is found. In this version, it is only set to 'wrong' if no valid name is found. 3. This uses a feature of python which allows you to iterate over the contents of a list directly - for name in names: print name[0] print name[1] if x == name[0] and y == name[1]: message = "right" break else: message = "wrong" Hope this gives you some ideas. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Creating a list with holes

2014-01-03 Thread Frank Millman
one, None, None, 'a'] >>> I wanted it because I was familiar with it from a previous language I had used. As is turns out, I never actually used it, but I was impressed! Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: nested dictionaries and functions in data structures.

2014-01-07 Thread Frank Millman
nary funct(addict[key1][key2]) # call the function with arguments This is usually compressed into one line - funct_call[var](addict[key1][key2]) This works if you always use the same arguments, no matter which function you call. Things get trickier if they differ. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Learning python networking

2014-01-15 Thread Frank Millman
lit(b'\n',1) return line.decode().replace('\r', '') Also, as I am looking at it, I notice that the second line should say - while b'\n' not in buffer: I feel a bit guilty nitpicking, as you have provided a wonderfully comprehensive answer, but I wanted to make sure the OP did not get confused. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: 'Stra�Ye' ('Strasse') and Python 2

2014-01-16 Thread Frank Millman
ou are putting in the effort to port ReportLab to python3, and I trust that you will get plenty of support from the gurus here in achieving this. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Self healthcheck

2014-01-22 Thread Frank Millman
ier)) In this case calling __del__() is safe, as no reference to the main object is held. If you do find that an object is not being deleted, it is then trial-and-error to find the problem and fix it. It is probably a circular reference HTH Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Self healthcheck

2014-01-22 Thread Frank Millman
"Asaf Las" wrote in message news:9729ddaa-5976-4e53-8584-6198b47b6...@googlegroups.com... > On Wednesday, January 22, 2014 10:56:30 AM UTC+2, Frank Millman wrote: >> >> class MainObject: >> def __init__(self, identifier): >> self._del = delwatch

Re: Python declarative

2014-01-24 Thread Frank Millman
More verbose - sure. Less human-readable - I don't think so. Also, intuitively one would think it would take much longer to process the XML version compared with the JSON version. I have not done any benchmarks, but I use lxml, and I am astonished at the speed. Admittedly a typical form-processor spends most of its time waiting for user input. Even so, for my purposes, I have never felt the slightest slowdown caused by XML. Comments welcome. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Python declarative

2014-01-24 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmo+euy439wb0c8or+zacyenr844hakwl3i2+55dde8...@mail.gmail.com... > On Fri, Jan 24, 2014 at 8:21 PM, Frank Millman wrote: >> I find that I am using JSON and XML more and more in my project, so I >> thought I would explain

Re: Python declarative

2014-01-24 Thread Frank Millman
"Rustom Mody" wrote in message news:39e1dd33-2162-40ea-8676-d27c8360a...@googlegroups.com... > On Friday, January 24, 2014 2:51:12 PM UTC+5:30, Frank Millman wrote: > Comments welcome. > > Of json/XML/yml I prefer yml because it has the terseness of json and the > stru

Re: Python declarative

2014-01-24 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmpi-kvJAVs2gK+nH5n6q3REkJaKR=czerfzugdk8_v...@mail.gmail.com... > On Fri, Jan 24, 2014 at 11:49 PM, Frank Millman > wrote: >> > [...] I have realised that we unlikely to come to an agreement on this in the near future

Re: Python declarative

2014-01-25 Thread Frank Millman
"Steven D'Aprano" wrote in message news:52e473fc$0$2$c3e8da3$54964...@news.astraweb.com... > On Sat, 25 Jan 2014 09:18:44 +0200, Frank Millman wrote: > >> I have realised that we unlikely to come to an agreement on this in the >> near future, as our phil

Re: Python declarative

2014-01-26 Thread Frank Millman
"Rustom Mody" wrote in message news:3683cd10-592b-4a3d-ba77-b963a1aa2...@googlegroups.com... > > Xml, originally a document format, is nowadays used as a data-format. > This conduces to humongous messing, first for the xml-library writers, and > thence to the users of those libraries because lib

Re: Sorting dictionary by datetime value

2014-02-08 Thread Frank Millman
', 3: 'pqr'} >>> sorted(d.items(), key=d.get) [(1, 'abc'), (2, 'xyz'), (3, 'pqr')] It did not crash, but it did not sort. Then I changed the keys to strings, to match Igor's example - >>> d = {'1': 'abc', '2': 'xyz', '3': 'pqr'} >>> sorted(d.items(), key=d.get) [('1', 'abc'), ('3', 'pqr'), ('2', 'xyz')] It works - now I am even more confused. Any hints will be appreciated. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Sorting dictionary by datetime value

2014-02-08 Thread Frank Millman
"Frank Millman" wrote in message news:ld4ocf$9rg$1...@ger.gmane.org... > > "Chris Angelico" wrote in message > news:captjjmqdusdfc1elbu6lf5-up__lae-63ii0uuvaggnem9u...@mail.gmail.com... >> On Sat, Feb 8, 2014 at 6:06 PM, Igor Korot wrote: >>&

Re: Sorting dictionary by datetime value

2014-02-08 Thread Frank Millman
"Peter Otten" <__pete...@web.de> wrote in message news:ld4pon$ni9$1...@ger.gmane.org... > Frank Millman wrote: > > Here you can watch the key calculation at work: > >>>> d = {'1': 'abc', '2': 'xyz', '3': &#

Re: Dictionaries

2014-02-08 Thread Frank Millman
ch iteration sets 'x' to the next key in dictionary 'a'. 'x' is a reference to a normal python object. It does not 'know' that it came from dictionary 'a', so you can do whatever you like with it. If you use it to retrieve a value in diction

Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
everts back to two decimal places. If I initialise the value as D('6049.05'), the next value is 6172.5, so it is not the number itself that causes the problem. I tried displaying the type - even when it switches to 6172.4999, it is still a Decimal type. I noticed one oddity - I am

Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Frank Millman
"Igor Korot" wrote in message news:CA+FnnTyaLLEsYGU7v2BreySDOQ1rVsMzJ=5f4iQTLW3=tn=e...@mail.gmail.com... Hi, > To: python-list@python.org > From: "Frank Millman" > Subject: Problem with sqlite3 and Decimal > Date: Fri, 11 Dec 2015 11:21:53 +0200 > Lines

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmor6newucco7xtsswyyfbgwcwz8jt-mjjkysjocfu7...@mail.gmail.com... On Fri, Dec 11, 2015 at 8:21 PM, Frank Millman wrote: > I noticed one oddity - I am asking sqlite3 to store the value as a > string, > but then I am asking it to

Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Frank Millman
"Igor Korot" wrote in message news:CA+FnnTyZY_1=62rbk_kkz39tkeoa6jvmfn9qs17as-2yd4d...@mail.gmail.com... Yes, I saw your post to sqlite3 ML. And I do know that by default sqlite3 does not have many types supported. However, all you need to do is save it as DECIMAL(10,2). It is supported is sql

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmoPXFSnXe1QA8MjjncBZBpqNkztha8YHJv=mbm--ze...@mail.gmail.com... On Sat, Dec 12, 2015 at 4:10 PM, Frank Millman wrote: > I can reproduce your example above. However, if I set the initial value > to > 5678.7, then the seque

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
"Frank Millman" wrote in message news:n4ei3l$b98$1...@ger.gmane.org... I need to store Decimal objects in a sqlite3 database, using Python 3.4 on Windows 7. I followed the instructions here - http://stackoverflow.com/questions/6319409/how-to-convert-python-decimal-to-sqlite-n

Re: Problem with sqlite3 and Decimal

2015-12-12 Thread Frank Millman
"Frank Millman" wrote in message news:n4gigr$f51$1...@ger.gmane.org... I have found a workaround for my problem, but first I needed to understand what was going on more clearly. This is what I have figured out. [...] The reason for the '#' in the above function is tha

Re: Problem with sqlite3 and Decimal

2015-12-12 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmrfw-qNx-a=3q2qj244fgvxz3mpe4wa-wdusmchxuf...@mail.gmail.com... On Sun, Dec 13, 2015 at 4:00 PM, Frank Millman wrote: > My new solution is to pass a 'scale' factor into my aggregate function. > The > function uses t

Stop writing Python 3.5 incompatible code :-)

2016-01-13 Thread Frank Millman
ged! Now, if 0 rows are returned, the message is 'not enough values to unpack'. Luckily the other message has not changed, so now my test is - except ValueError as e: if str(e).startswith('too many'): # > 1 rows returned else: # 0 rows returned Now it

Re: Stop writing Python 3.5 incompatible code :-)

2016-01-13 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmps+vfu33tulae5oivrvn_otfuxrp8yluy68qmu36-...@mail.gmail.com... On Thu, Jan 14, 2016 at 5:27 PM, Frank Millman wrote: > Using LBYL, one would retrieve the row(s) and check the length. I found > a > way to use EAFP, as follow

Re: Stop writing Python 3.5 incompatible code :-)

2016-01-14 Thread Frank Millman
"Frank Millman" wrote in message news:n77j78$ld0$1...@ger.gmane.org... cur.execute(...) try: row = next(cur) except StopIteration: # 0 rows returned try: next(cur) except StopIteration: pass else: # >1 rows returned For the record, I just tried this and found an

Re: Single format descriptor for list

2016-01-20 Thread Frank Millman
"format" still doesn't quite do the job: >>> a = range(4, 8) >>> print ('th\n'.join(map(str,a))) 4th 5th 6th 7 Is there an elegant way to print-format an arbitrary length list? How about this - a = range(4, 8) print('\n'.join(['{}t

Installing on linux - missing devel packages

2016-01-20 Thread Frank Millman
there an easy way to find out all the missing components, so that when the installation is complete I can be sure I have the entire standard lib? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Installing on linux - missing devel packages

2016-01-21 Thread Frank Millman
On 2016-01-21, Chris Angelico wrote: On Thu, Jan 21, 2016 at 6:18 PM, Frank Millman wrote: Fedora 22 comes standard with Python 3.4.2. I want to install 3.5.1. It is easy enough to download the source and run ./configure;make;make altinstall. But then I find that I cannot import gzip because

Question about asyncio and blocking operations

2016-01-23 Thread Frank Millman
if what I am going through sounds normal, or if I am doing something fundamentally wrong. Thanks for any input Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about asyncio and blocking operations

2016-01-23 Thread Frank Millman
"Frank Millman" wrote in message news:n8038j$575$1...@ger.gmane.org... So I thought I would ask here if anyone has been through a similar exercise, and if what I am going through sounds normal, or if I am doing something fundamentally wrong. Thanks for any input Just a qui

Re: Question about asyncio and blocking operations

2016-01-25 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidngogpx+cpmvba8vpefuq4-bwmvs0gz3shb0owzi0b...@mail.gmail.com... On Sat, Jan 23, 2016 at 7:38 AM, Frank Millman wrote: > Here is the difficulty. The recommended way to handle a blocking > operation > is to run it as task in a diff

Re: Question about asyncio and blocking operations

2016-01-25 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidngogpx+cpmvba8vpefuq4-bwmvs0gz3shb0owzi0b...@mail.gmail.com... On Sat, Jan 23, 2016 at 7:38 AM, Frank Millman wrote: > Here is the difficulty. The recommended way to handle a blocking > operation > is to run it as task in a diff

Re: Question about asyncio and blocking operations

2016-01-26 Thread Frank Millman
"Frank Millman" wrote in message news:n8038j$575$1...@ger.gmane.org... I am developing a typical accounting/business application which involves a front-end allowing clients to access the system, a back-end connecting to a database, and a middle layer that glues it al

Re: Question about asyncio and blocking operations

2016-01-27 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzidk-RBkB-vi6CgcEeoFHQrsoTFvqX9MqzDD=rny5boc...@mail.gmail.com... On Tue, Jan 26, 2016 at 7:15 AM, Frank Millman wrote: > > If I return the cursor, I can iterate over it, but isn't this a blocking > operation? As far as I know,

Re: Question about asyncio and blocking operations

2016-01-27 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidn6tvn9w-2qnn2jyvju8nhzn499nptfjn9ohjddceb...@mail.gmail.com... On Wed, Jan 27, 2016 at 7:40 AM, Frank Millman wrote: > > Assume a slow function - > > async def slow_function(arg1, arg2): >[do stuff] > > It now

Re: Question about asyncio and blocking operations

2016-01-27 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzidk-RBkB-vi6CgcEeoFHQrsoTFvqX9MqzDD=rny5boc...@mail.gmail.com... On Tue, Jan 26, 2016 at 7:15 AM, Frank Millman wrote: > > If I return the cursor, I can iterate over it, but isn't this a blocking > operation? As far as I know,

Re: Question about asyncio and blocking operations

2016-01-28 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzidkr-fT6S6wH2caNaxyQvUdAw=x7xdqkqofnrrwzwnj...@mail.gmail.com... On Wed, Jan 27, 2016 at 10:14 AM, Ian Kelly wrote: > Unfortunately this doesn't actually work at present. > EventLoop.run_in_executor swallows the StopIteration exception and > just returns

Re: Question about asyncio and blocking operations

2016-01-28 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmr162+k4lzefpxrur6wxrhxbr-_wkrclldyr7kst+k...@mail.gmail.com... On Thu, Jan 28, 2016 at 8:13 PM, Frank Millman wrote: > Run the database handler in a separate thread. Use a queue.Queue to send > requests to the handler. Use an async

Re: Question about asyncio and blocking operations

2016-01-28 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzidnGbz7kM=d7mkua2ta9-csfn9u0ohl0w-x5bbixpcw...@mail.gmail.com... On Jan 28, 2016 4:13 AM, "Frank Millman" wrote: > > I *think* I have this one covered. When the caller makes a request, it creates an instance of an asyncio.Queue

Re: Question about asyncio and blocking operations

2016-01-28 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidn6nft_o0cfhw1itwja81+mw3schuecadvcen3ix6z...@mail.gmail.com... As I commented in my previous message, asyncio.Queue is not thread-safe, so it's very important that the put calls here be done on the event loop thread using event_loop.call_soon_threadsafe.

Re: Question about asyncio and blocking operations

2016-01-29 Thread Frank Millman
"Frank Millman" wrote in message news:n8et0d$hem$1...@ger.gmane.org... I have read the other messages, and I can see that there are some clever ideas there. However, having found something that seems to work and that I feel comfortable with, I plan to run with this for the time

Cannot step through asynchronous iterator manually

2016-01-30 Thread Frank Millman
cannot find it. I can achieve the desired result by calling 'await aiter.__anext__()', but this is clunky. Am I missing something? Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzid=ssdsm8hdan+orj54a_jeu9wc8103iqgkaah8mrj-...@mail.gmail.com... On Jan 29, 2016 11:04 PM, "Frank Millman" wrote: > > Hi all > > To loop though an iterator one usually uses a higher-level construct > such as a '

Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Frank Millman
"Maxime S" wrote in message news:CAGqiJR8yUdd1u7j0YHS-He_v4uUT-ui=PpiX=n_G=ntt8zn...@mail.gmail.com... I might be a bit off-topic, but why don't you simply use cursor.rowcount? I just tried that on sqlite3 and pyodbc, and they both return -1. I think that it only works with insert/update/

Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmoAmVNTCKq7QYaDRNQ67Gcg9TxSXYXCrY==s9djjna...@mail.gmail.com... On Sat, Jan 30, 2016 at 7:22 PM, Frank Millman wrote: > We had a recent discussion about the best way to do this, and ChrisA > suggested the followin

Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Frank Millman
"Oscar Benjamin" wrote in message news:cahvvxxsa0yq4voyy6qycgxxvpl5zzgm8muui+1vmezd8crg...@mail.gmail.com... The simplest thing would just be to call list(cur) but I realise that you don't want to consume more than 2 rows from the database so just use islice: rows = list(islice(cur, 2)) # p

Question about official API

2016-02-05 Thread Frank Millman
to in the documentation for 'task_done()'. I tried it out, and it does exactly what I want. However, it is not mentioned in the documentation. How do I know if it is safe to rely on this? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about official API

2016-02-05 Thread Frank Millman
"Lutz Horn" wrote in message news:blu178-w1837247af25e5755af69eb9e...@phx.gbl... Hi, > What is the rule for knowing if something is part of the official API? Look into https://docs.python.org/3/library/ Thanks for the link, Lutz. Unfortunately I may have asked the wrong question. In my

Re: Question about official API

2016-02-05 Thread Frank Millman
"Frank Millman" wrote in message news:n91ndn$sc1$1...@ger.gmane.org... Thanks for the link, Lutz. Unfortunately I may have asked the wrong question. In my specific case, how do I know if it is safe to use the attribute 'unfinished_tasks' in the class queue.Queue? It

asyncio - how to stop background task cleanly

2016-02-06 Thread Frank Millman
sleep' using wait() with a timeout value, but reacts instantly when set() is called, so it was ideal. Is there a way to achieve this using asyncio? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87lh6ys052@elektro.pacujo.net... "Frank Millman" : > When shutting the main program down, I want to stop the task, but I > cannot figure out how to stop it cleanly - i.e. wait until it has > finished the current tas

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:8737t5shhp@elektro.pacujo.net... > Actually, cancellation is specially supported in asyncio (https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel>) so this should do: async def background_task(): while True: a

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Frank Millman
"Frank Millman" wrote in message news:n96kjr$mvl$1...@ger.gmane.org... "Marko Rauhamaa" wrote in message news:8737t5shhp@elektro.pacujo.net... > Actually, cancellation is specially supported in asyncio ( https://docs.python.org/3/library/asyncio-task.html#asy

Re: asyncio - how to stop background task cleanly

2016-02-07 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87r3gpq7mi@elektro.pacujo.net... I can't see your complete program, but here's mine, and it seems to be working Thanks, Marko, I really appreciate your assistance. I wanted to show you my complete program, but as it is quite long I distilled it

Re: asyncio - how to stop background task cleanly

2016-02-07 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:871t8orhua@elektro.pacujo.net... "Frank Millman" : > I have never been able to get Ctrl+C to work properly on Windows, so I > use a separate thread that simply waits for Enter. Now you are leaving my realm of expertise, a

asyncio and blocking - an update

2016-02-08 Thread Frank Millman
ing function to process each row, the overhead of call_soon_threadsafe() would be minimised and my approach might be effective. For now, however, I will regretfully abandon my approach and stick with run_in_executor(). Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Handling transactions in Python DBI module

2016-02-10 Thread Frank Millman
esets the state to 'not'. I learned the hard way that it is important to use conn.commit() and not cur.execute('commit'). Both succeed in committing, but the second does not reset the state, therefore the next statement does not trigger a 'BEGIN', with possible unfortunate side-effects. HTH Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Handling transactions in Python DBI module

2016-02-10 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmphjvtckub6qr-vp_1epewxbgqxmfkepmohqp3papg...@mail.gmail.com... When I advise my students on basic databasing concepts, I recommend this structure: conn = psycopg2.connect(...) with conn, conn.cursor() as cur: cur.execute(...) Does this auto

Re: asyncio and blocking - an update

2016-02-10 Thread Frank Millman
"Frank Millman" wrote in message news:n9c4p3$gmp$1...@ger.gmane.org... Some of you may have been following my attempts to modify my asyncio app so that it does not block when accessing the database. Here is an update. Here is an update to my update ... I came up with what f

Re: asyncio and blocking - an update

2016-02-10 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmrVCkKAEevc9TW8FYYTnZgRUMPHectz+bD=dqrphxy...@mail.gmail.com... Something worth checking would be real-world database performance metrics [snip lots of valid questions] My approach is guided by something I read a long time ago, and I don't know h

Re: asyncio and blocking - an update

2016-02-11 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmor8dMv2TDtq8RHQgWeSAaZgAmxK9gFth=oojhidwh...@mail.gmail.com... So really, the question is: Is this complexity buying you enough performance that it's worthwhile? Indeed, that is the question. Actually, in my case it is not quite the question. F

Re: asyncio and blocking - an update

2016-02-12 Thread Frank Millman
"Frank Millman" wrote in message news:n9hjfp$ad7$1...@ger.gmane.org... However, my concern is not to maximise database performance, but to ensure that in an asynchronous environment, one task does not block the others from responding. My tests simulate a number of tasks running co

asyncio - run coroutine in the background

2016-02-14 Thread Frank Millman
= BackgroundTask() args = (arg1, arg2 ...) callback = my_callback_function await bg_task.run(coro, args, callback) Although it 'awaits' bk_task.run(), it returns immediately, as it is simply waiting for run_in_executor() to be launched. Hope this is of some interest. Fra

Re: asyncio - run coroutine in the background

2016-02-14 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:8737sumpjl@elektro.pacujo.net... "Frank Millman" : > Using asyncio, there are times when I want to execute a coroutine which > is time-consuming. I do not need the result immediately, and I do not > want to block the curr

Re: asyncio - run coroutine in the background

2016-02-15 Thread Frank Millman
"Paul Rubin" wrote in message news:87h9ha8lt0@jester.gateway.pace.com... "Frank Millman" writes: > The benefit of my class is that it enables me to take the coroutine > and run it in another thread, without having to re-engineer the whole > thing. Th

Re: asyncio - run coroutine in the background

2016-02-16 Thread Frank Millman
"Kevin Conway" wrote in message news:CAKF=+dim8wzprvm86_v2w5-xsopcchvgm0hy8r4xehdyzy_...@mail.gmail.com... If you're handling coroutines there is an asyncio facility for "background tasks". The ensure_future [1] will take a coroutine, attach it to a Task, and return a future to you that resolve

Re: asyncio - run coroutine in the background

2016-02-16 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87d1rwpwo2@elektro.pacujo.net... Kevin Conway : > If you're handling coroutines there is an asyncio facility for > "background tasks". The ensure_future [1] will take a coroutine, > attach it to a Task, and return a future to you that resolves when th

Re: asyncio - run coroutine in the background

2016-02-16 Thread Frank Millman
"Kevin Conway" wrote in message news:CAKF=+dhXZ=yax8stawr_gjx3tg8yujprjg-7ym2_brv2kxm...@mail.gmail.com... > My background task does take a long time to run - about 10 seconds - but > most of that time is spent waiting for database responses, which is > handled > in another thread. Something

Re: asyncio - run coroutine in the background

2016-02-16 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmqmie4groqnyvhwahcn2mwqeyqxt5kvfivotrhqy-s...@mail.gmail.com... On Wed, Feb 17, 2016 at 2:21 AM, Frank Millman wrote: > I would love to drive the database asynchronously, but of the three > databases I use, only psycopg2 seems

Re: SQLite3 in Python 2.7 Rejecting Foreign Key Insert

2014-11-23 Thread Frank Millman
hen include the remote table in any sql command. However, it will not enforce foreign key constraints across databases. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: SQLite3 in Python 2.7 Rejecting Foreign Key Insert

2014-11-24 Thread Frank Millman
"Dennis Lee Bieber" wrote in message news:8d747a5biq4rc559tvgju088508bp0o...@4ax.com... > On Sun, 23 Nov 2014 10:21:48 +0200, "Frank Millman" > declaimed the following: > >> >> >>The default is for sqlite3 to ignore foreign key contraints. >>

Re: SQLite3 in Python 2.7 Rejecting Foreign Key Insert

2014-11-24 Thread Frank Millman
"Dennis Lee Bieber" wrote in message news:lrr67al6ppa852agu9rq2dstqtue17i...@4ax.com... > On Mon, 24 Nov 2014 10:05:11 +0200, "Frank Millman" > declaimed the following: > >> >>Originally I supported two databases - PostgreSQL and Sql Server. They

Db transactions and locking

2014-11-27 Thread Frank Millman
7;t know if Sql Server and sqlite3 behave the same, but I don't think it can do any harm, so I let it apply across the board. Can anyone see any problem with this? Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Db transactions and locking

2014-11-27 Thread Frank Millman
"Dennis Lee Bieber" wrote in message news:4loe7at2ls7tfq0oe041ru9svvsm8ak...@4ax.com... > On Thu, 27 Nov 2014 12:24:39 +0200, "Frank Millman" > declaimed the following: > > >>All Python database adaptors that I have used start a transaction when you >&

Re: Db transactions and locking

2014-11-27 Thread Frank Millman
"Frank Millman" wrote in message news:m5924d$nbq$1...@ger.gmane.org... > > > This seems to confirm what I thought, but then I continued, and was > surprised at the result. > > I can repeat these lines at will - > > cur.execute('SELECT * FROM mytable&#x

<    1   2   3   4   5   6   7   8   >