Subversion Repositories SmartDukaan

Rev

Rev 12214 | Rev 12218 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12214 Rev 12216
Line 31... Line 31...
31
import email
31
import email
32
from email.mime.multipart import MIMEMultipart
32
from email.mime.multipart import MIMEMultipart
33
import email.encoders
33
import email.encoders
34
import cookielib
34
import cookielib
35
from multiprocessing import Pool
35
from multiprocessing import Pool
36
from multiprocessing.dummy import Pool as ThreadPool 
36
from multiprocessing.dummy import Pool as ThreadPool
-
 
37
from threading import Thread
37
 
38
 
38
config_client = ConfigClient()
39
config_client = ConfigClient()
39
host = config_client.get_property('staging_hostname')
40
host = config_client.get_property('staging_hostname')
40
syncPrice=config_client.get_property('sync_price_on_marketplace')
41
syncPrice=config_client.get_property('sync_price_on_marketplace')
41
 
42
 
Line 2150... Line 2151...
2150
    else:
2151
    else:
2151
        count = 0
2152
        count = 0
2152
        pool = ThreadPool(50)
2153
        pool = ThreadPool(50)
2153
        startOffset = 0
2154
        startOffset = 0
2154
        endOffset = startOffset
2155
        endOffset = startOffset
-
 
2156
        threads = []
2155
        while(count<1 and endOffset<len(itemInfo)):
2157
        while(count<50 and endOffset<len(itemInfo)):
2156
            endOffset = startOffset + 50
2158
            endOffset = startOffset + 1
2157
            if (endOffset >= len(itemInfo)):
2159
            if (endOffset >= len(itemInfo)):
2158
                endOffset = len(itemInfo)
2160
                endOffset = len(itemInfo)
2159
            print "pool offset start end count"+str(startOffset)+" "+str(endOffset)+" "+str(count)
2161
            print "pool offset start end count"+str(startOffset)+" "+str(endOffset)+" "+str(count)
-
 
2162
            t = Thread(target=populateScrapingResults, args=(itemInfo[startOffset],))
-
 
2163
            t.start()
-
 
2164
            threads.append(t)
2160
            pool.map(populateScrapingResults,itemInfo[startOffset:endOffset])
2165
            #pool.map(populateScrapingResults,itemInfo[startOffset:endOffset])
2161
            #t = Process(target=decideCategory,args=(itemInfo[startOffset:endOffset], scraper))
2166
            #t = Process(target=decideCategory,args=(itemInfo[startOffset:endOffset], scraper))
2162
            #t = threading.Thread(target=partial(decideCategory, itemInfo[startOffset:endOffset], scraper))
2167
            #t = threading.Thread(target=partial(decideCategory, itemInfo[startOffset:endOffset], scraper))
2163
            #t = threading.Thread(target=partial(test, startOffset, endOffset))
2168
            #t = threading.Thread(target=partial(test, startOffset, endOffset))
2164
            #threads.append(t)
2169
            #threads.append(t)
2165
            startOffset = startOffset + 50
2170
            startOffset = startOffset + 1
2166
            count+=1
2171
            count+=1
2167
        #[t.start() for t in threads]
2172
        #[t.start() for t in threads]
2168
        #[t.join() for t in threads] 
2173
        #[t.join() for t in threads] 
2169
        #threads = []
2174
        #threads = []
2170
        print "terminating while"
2175
        print "terminating while"
2171
        pool.close()
2176
#        pool.close()
2172
        pool.join()
2177
#        pool.join()
-
 
2178
        for thread in threads:
-
 
2179
            thread.join()
2173
        print "joining threads"
2180
        print "joining threads"
2174
        print "returning offset******"
2181
        print "returning offset******"
2175
        return endOffset
2182
        return endOffset
2176
    
2183
    
2177
def sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease):
2184
def sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease):