Hi All,

I am facing issues with handling several request in parallel from same user.
When I submit one job and then simultaneously try to open my server 
homepage in new tab, it waits until first one finishes. I went through some 
earlier answers regarding this and came to know that there is some issue 
with session but I am not aware how to resolve this using session.forget() 
or where to put this in my code. I tried to put this in one function in my 
code but it doesn't allow my job to run further.

I have also used session variable in my views/html file...

I have attached my sample code...

Thanks

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def index():
    values= ['','MMP2', 'MMP3']


    form=FORM(TABLE(TR('Select name:',SELECT(values,requires=IS_NOT_EMPTY("please choose one name"),_name='protease',_onchange="jQuery.post('%s',{'protease':jQuery(this).val()})" % URL('mmp'))),
    				TR('Uniprot ID:',INPUT(_name='uniprot')),
    				TR("",INPUT(_type="submit",_value="SUBMIT",_onclick="javascript:$.blockUI({message: $('#domMessage') });"))))
    form.element('input[type=submit]',replace=lambda button: CAT(button, INPUT(_class="btn",_type="reset",_value="Reset")))

    
    if form.process().accepted:
    	if form.vars.uniprot <> '':
    		session.uniprot = form.vars.uniprot
        	redirect(URL('result'))
        else:
        	response.flash = T("Enter Uniprot ID or Fasta Seq or upload PDB file or enter PDB ID:")

    return dict(form=form)

def uniprot_merops():
    mmpn=""    
    if session.protease == "MMP2":
        mmpn = "P08253"
    elif session.protease == "MMP3":
        mmpn = "P08254" 
    
    geneid=[]
    genemmpid=[]
    idmapfile = os.path.join(request.folder, 'private', 'idmapmapping_new.data')
    with open(idmapfile, 'rU') as id:
        for row in id.readlines():
            idmap = row.strip().split('\t')
            if session.uniprot == idmap[0] and idmap[1] == 'GeneID':
                geneid.append(idmap[2])
            if mmpn == idmap[0] and idmap[1] == 'GeneID':
                genemmpid.append(idmap[2])
        id.close()

    if len(genemmpid) > 0:
        geneid7 = genemmpid[0].strip()
    else:
        geneid7 = 0
    if len(geneid) > 0:
        geneid3 = geneid[0].strip()
    else:
        geneid3 = 0

    temp4 = os.path.join(request.folder, 'private')
    dirpath = tempfile.mkdtemp(dir=temp4)

    url1 = 'http://www.uniprot.org/uniprot/' + session.uniprot + '.fasta'
    req_seq = urllib2.Request(url1)
    resp_seq = urllib2.urlopen(req_seq).read()
    t = resp_seq.split("\n")
    t1 = t[1:-1]
    sequence = ''.join(t1)


#predict cleavage
    temp = os.path.join(request.folder, dirpath)
    
    f1 = tempfile.NamedTemporaryFile(suffix='.fa',delete=False, dir=temp)
    f1.write(resp_seq)
    f1.seek(0)
    f1.close()
    tempo1 = os.path.join(request.folder, temp,f1.name)

    cmd1 = os.path.join(request.folder, 'private', 'Run.MMP_cuts_pred_fa_HT')
    cmd2 = os.path.join(request.folder, 'private')
    cmd3 = str(session.protease)

    proc = subprocess.Popen([cmd1,tempo1,cmd3], cwd=temp)
    proc.communicate()

    cleavage_result =  glob.glob(os.path.join(request.folder, temp, '*.dat')) 

    cleavage_res = []
    for line in open(cleavage_result[0]):
            cleavage_res.append(line.rstrip('\n').split())
 
    os.unlink(cleavage_result[0])     
        
    return dict(fasta=resp_seq, seq=sequence, cleavage_res=cleavage_res, mmp_no=cmd3, geneid7=geneid7, temp=temp)


def result():

    return uniprot_merops()

Reply via email to