Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

yes, thanks. fork() duplicating all handles, will create a mess and on top of that, it will try to close all duplicated handles on exit of child (with commits or rollbacks etc) even if child has not opened any itself! This last will be a hard nut to debug.

The only thing it remains foggy, to me, is how testing should go with fork. To start with, test numbers are mixed and Test::More is randomly confused and fails. Using Test::Fork fixes that but with loosing test numbers which takes me to the real problem: I have to ensure a sequence. First the child opens the DB and locks it, *next* the parent opens the same DB and checks if it's locked and does whatever it has to do on it. That's why I have a sleep() just as the parent starts, to give time to child to lock the DB. But that's not guaranteed at all, although chances are miniscule.

I believe/read that single SQLite DB is ok being accessed concurrently by many processes.

Update: in a sort of rubber-ducking-way, I guess I don't need a fork at all!

Just open the DB first and lock it, don't close it. Next (and sequentially), open the same DB and check if it's locked etc. At the end close both connections to the same DB. BTW my test case is to be able to just read the DB when it is locked, nothing fancy more than read. The real situation is Firefox locking aggressively its cookies SQLite db and I can not read the current cookies when FF is running.


In reply to Re^2: Locking a SQLite DB for tests by bliako
in thread Locking a SQLite DB for tests by bliako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found